Technical Article

Generating WITH MOVE Statements

,

Generating WITH MOVE Statements for restoring backups on a different servers which has different disk layout.

declare @logicalvarchar(25),
@physicalvarchar(50),
@printmsgvarchar(255)

declare sysfiles_csr cursor for
select name, filename
from sysfiles
order by fileid

OPEN sysfiles_csr
FETCH sysfiles_csr INTO @logical, @physical

WHILE (@@FETCH_STATUS = 0)
begin

set @printmsg = 'move ''' + @logical + ''' to ''' + @physical + ''','
print @printmsg

FETCH sysfiles_csr INTO @logical, @physical
end

close sysfiles_csr
deallocate sysfiles_csr

Rate

You rated this post out of 5. Change rating

Share

Share

Rate

You rated this post out of 5. Change rating