Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 restore query with multiple backup sets

Author  Topic 

p-vd-berg
Starting Member

4 Posts

Posted - 2011-10-24 : 04:19:12
Iam using MySQL 2005. I want to use a query te restore a database. The query is:
RESTORE DATABASE MediscoreMIM_Test2_Patrick FROM DISK='D:\SQL\MetaVision2005\Backup\MediscoreMIM_Test2_Patrick.bak' WITH REPLACE"

In my backup file I have 5 backup sets. When i'am running the query it uses the first backup set (with is the oldest). I want to use the latest backup set.

My question is: How should I modify the query so that the last (newest) backup set is used?

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-10-24 : 04:28:55
http://www.siusic.com/wphchen/restore-the-latest-database-backup-automatically-and-xp_dirtree-324.html

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

Lumbago
Norsk Yak Master

3271 Posts

Posted - 2011-10-24 : 04:29:10
Use WITH FILE = x where x is the number in the backupset. Like this:

...WITH REPLACE, FILE=5

- Lumbago
My blog-> http://thefirstsql.com/2011/07/08/how-to-find-gaps-in-identity-columns-at-the-speed-of-light/
Go to Top of Page

Lumbago
Norsk Yak Master

3271 Posts

Posted - 2011-10-24 : 04:30:27
That being said: you will save yourself a lot of hassle by keeping each backupset in a different file.

- Lumbago
My blog-> http://thefirstsql.com/2011/07/08/how-to-find-gaps-in-identity-columns-at-the-speed-of-light/
Go to Top of Page

p-vd-berg
Starting Member

4 Posts

Posted - 2011-10-24 : 04:44:48
quote:
Originally posted by Lumbago

Use WITH FILE = x where x is the number in the backupset. Like this:

...WITH REPLACE, FILE=5

- Lumbago
My blog-> http://thefirstsql.com/2011/07/08/how-to-find-gaps-in-identity-columns-at-the-speed-of-light/



Thanks! It works perfect.

quote:
Originally posted by Lumbago

That being said: you will save yourself a lot of hassle by keeping each backupset in a different file.

- Lumbago
My blog-> http://thefirstsql.com/2011/07/08/how-to-find-gaps-in-identity-columns-at-the-speed-of-light/



Yeah i know, but try it te explain to my boss
Go to Top of Page

Lumbago
Norsk Yak Master

3271 Posts

Posted - 2011-10-24 : 04:51:03
Excellent! And you should show your boss this thread then ;)

- Lumbago
My blog-> http://thefirstsql.com/2011/07/08/how-to-find-gaps-in-identity-columns-at-the-speed-of-light/
Go to Top of Page
   

- Advertisement -