August 14, 2008 at 3:21 am
Hi , can anyone help me about dynamic sql. I try to write an automatic restore script. But i don't know the syntax and i get always errors.
i don't know how to add "@variable" into a Move to command
Here's the script :
declare @newBase nvarchar(4000)
declare @backupDevice nvarchar(4000)
set @newBase = 'try_restore2'
set @backupDevice = 'BackupDevice_Name'
RESTORE DATABASE @newBase FROM @backupDevice
WITH FILE = 1,
MOVE @backupDevice + '_data' TO 'e:\MSSQL\data\'+ @newBase + '_Data.MDF''',
MOVE @backupDevice + '_log' TO 'e:\MSSQL\data\'+ @newBase + '_Log.LDF''',
STANDBY = N'e:\MSSQL\BACKUP\ROLLBACK_UNDO_' + @backupDevice + '.BAK',
NOUNLOAD, STATS = 10
GO
Thanks for any help.
August 14, 2008 at 5:17 am
Please don't cross post. It just wastes people's time and fragments replies. Many of us read all the forums.
No replies to this thread please. Direct replies to:
http://www.sqlservercentral.com/Forums/Topic552520-146-1.aspx
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply