Friends...
Os: win2k3
DB: sql server 2008
I am planning to restore the latest backup set from production to test db. i have to get the max position from the restore headeronly command to a variable and pass it to restore command.
i have written this query..but iam still facing some problem in executing this query.
declare @position1 as int
declare @tempsql1 nvarchar(max)
set @tempsql1='RESTORE HEADERONLY FROM DISK = ''D:\DailyDBbackup\ciet.BAK''';
execute(@tempsql1); ======== upto this statement working fine...
SELECT @position1 = MAX(position) FROM @tempsql1 WHERE BackupType = 1 AND BackupName = 'ciet-Full Database Backup';
'Here @tempsql1 is not getting the value from the above variable. i am getting the error as Must declare the table variable "@tempsql1".
RESTORE DATABASE ciet FROM DISK = 'D:\DailyDBbackup\ciet.BAK'
WITH FILE = @position1;
can anybody correct this error?
thanks & regards