troubleshooting Question

MSSQL Restore

Avatar of ncammann
ncammannFlag for United Kingdom of Great Britain and Northern Ireland asked on
Microsoft SQL ServerMicrosoft SQL Server 2008
1 Comment1 Solution274 ViewsLast Modified:
I have a developement SQL server that I would like to restore  copies from two Live database  on a weekly basis. I need to be able to trust a less technical person to do this on occasion so wanted to script it. However the backup file passed from the production server has a name -
"database_backup_2012_02_07_4905093" etc.
in other words they are (usefully) data and time stamped & serial numbered.
Is there a way within the T-SQL script to allow for this?
RESTORE DATABASE [Membership] FILE = N'Membership' FROM  DISK = N'E:\Membership_backup_2012_02_07_010001_4905093.bak' WITH  FILE = 1,  MOVE N'Membership' TO N'C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\Membership.mdf',  MOVE N'Membership_log' TO N'C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\Membership.ldf',  NOUNLOAD,  STATS = 10


Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 1 Comment.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 1 Comment.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros