Link to home
Start Free TrialLog in
Avatar of ncammann
ncammannFlag for United Kingdom of Great Britain and Northern Ireland

asked on

MSSQL Restore

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
GO
-------------------------------------------------------------

Thanks

Nigel
ASKER CERTIFIED SOLUTION
Avatar of lcohan
lcohan
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial