Generating WITH MOVE Statements

,

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

declare @logical	varchar(25),
	@physical	varchar(50),
	@printmsg	varchar(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

Share

Share

Rate