Drop Table

Support Forum for database administrators and web based access to important newsgroups related to databases
Register on Database Support Forum Edit your profileCalendarFind other Database Support forum membersFrequently Asked QuestionsSearch this forum -> 
For Database admins: Free Database-related Magazines Now Free shipping to Texas


Post New Thread










Thread
Author

restore complete backup
Hello,

Does anyone has an example script how to restore a complete database
with transaction log?

Thnx

Report this thread to moderator Post Follow-up to this message
Old Post
Jason
09-29-05 02:23 PM


Re: restore complete backup
Jason
create database test
GO
create table test..test(id int identity)
insert test..test default values
backup database test to disk = 'd:\db.bak' WITH INIT
insert test..test default values
backup log test to disk = 'd:\log.bak'WITH INIT
insert test..test default values
backup log test to disk = 'd:\log.bak' WITH NOINIT
GO
RESTORE DATABASE test FROM disk = 'd:\db.bak' WITH FILE = 1, norecovery
RESTORE LOG test FROM disk = 'd:\log.bak' WITH FILE = 1, norecovery
RESTORE LOG test FROM disk = 'd:\log.bak' WITH FILE = 2, recovery

"Jason" <jasonlewis@hotrmail.com> wrote in message
news:exy2NPPxFHA.2720@TK2MSFTNGP10.phx.gbl...
> Hello,
>
> Does anyone has an example script how to restore a complete database with
> transaction log?
>
> Thnx



Report this thread to moderator Post Follow-up to this message
Old Post
Uri Dimant
09-29-05 02:23 PM


Re: restore complete backup
Uri Dimant  wrote:
> Jason
> create database test
> GO
> create table test..test(id int identity)
> insert test..test default values
> backup database test to disk = 'd:\db.bak' WITH INIT
> insert test..test default values
> backup log test to disk = 'd:\log.bak'WITH INIT
> insert test..test default values
> backup log test to disk = 'd:\log.bak' WITH NOINIT
> GO
> RESTORE DATABASE test FROM disk = 'd:\db.bak' WITH FILE = 1, norecovery
> RESTORE LOG test FROM disk = 'd:\log.bak' WITH FILE = 1, norecovery
> RESTORE LOG test FROM disk = 'd:\log.bak' WITH FILE = 2, recovery
>
> "Jason" <jasonlewis@hotrmail.com> wrote in message
> news:exy2NPPxFHA.2720@TK2MSFTNGP10.phx.gbl...
> 
>
>
>
Hi Uri,

And how about the filenumber? I have a backupdevice where the backups
adds on a daily basis. How can i always use the last backup added.

Report this thread to moderator Post Follow-up to this message
Old Post
Jason
09-29-05 04:23 PM


Re: restore complete backup
Hi,

You can query the max position for the backup file in  MSDB..BACKUPSET
table. Use the below query as sample.

SELECT MAX(POSITION) FROM MSDB..BACKUPSET A
inner join MSDB..BACKUPMEDIAFAMILY b
ON A.MEDIA_SET_ID = B.MEDIA_SET_ID
AND   PHYSICAL_DEVICE_NAME
='C:\MAST.BAK'

You can give the output in the Restore statement.

Thanks
Hari
SQL Server MVP


"Jason" <jasonlewis@hotrmail.com> wrote in message
news:uONG9GQxFHA.900@TK2MSFTNGP11.phx.gbl...
> Uri Dimant wrote: 
> Hi Uri,
>
> And how about the filenumber? I have a backupdevice where the backups adds
> on a daily basis. How can i always use the last backup added.



Report this thread to moderator Post Follow-up to this message
Old Post
Hari Prasad
09-30-05 01:23 AM


Re: restore complete backup
Hari Prasad  wrote:
> Hi,
>
> You can query the max position for the backup file in  MSDB..BACKUPSET
> table. Use the below query as sample.
>
> SELECT MAX(POSITION) FROM MSDB..BACKUPSET A
>             inner join MSDB..BACKUPMEDIAFAMILY b
>        ON A.MEDIA_SET_ID = B.MEDIA_SET_ID
>        AND   PHYSICAL_DEVICE_NAME
='C:\MAST.BAK'
>
> You can give the output in the Restore statement.
>
> Thanks
> Hari
> SQL Server MVP
>
>
> "Jason" <jasonlewis@hotrmail.com> wrote in message
> news:uONG9GQxFHA.900@TK2MSFTNGP11.phx.gbl...
> 
>
>
>
Hi,

I'm getting the wrong number returned from your example. If i check the
backup, there are 3 files in it. When i execute your example it says 6.

Is there something missing?


Report this thread to moderator Post Follow-up to this message
Old Post
Jason
09-30-05 12:23 PM


Sponsored Links





Last Thread Next Thread
Post New Thread

MS SQL Server archive

Show a Printable Version Email This Page to Someone! Receive updates to this thread
Microsoft SQL Server
Access database support
PostgreSQL Replication
SQL Server ODBC
FoxPro Support
PostgreSQL pgAdmin
SQL Server Clustering
MySQL ODBC
Web Applications with dBASE
SQL Server CE
MySQL++
Sybase Database Support
MS SQL Full Text Search
PostgreSQL Administration
SQL Anywhere support
DB2 UDB Database
Paradox Database Support
Filemaker Database
Berkley DB
SQL 2000/2000i database
ASE Database
Forum Jump:
All times are GMT. The time now is 12:54 PM.

 
Mobile devices forum | Database support forum archive




Copyrights DropTable.com Database Support Forum 2004 - 2006