ресторинг n баз из одного бэкапа под разными именами

declare @name nvarchar(56)

declare @cmd nvarchar(512)

DECLARE @Cursor CURSOR

SET @Cursor = CURSOR FOR

select '0'+right(servername,2) as name from s0055.rkur_dbastat.dbo.ServerName

where is_disable = 0

--and servername = 's1027'

 

OPEN @Cursor

FETCH NEXT FROM @Cursor INTO @name

 

WHILE (@@FETCH_STATUS = 0)

BEGIN

print @name

set @cmd = 'RESTORE DATABASE [planograms'+@name+'] 

FROM DISK= N''H:\MSSQL\Backup\etalon_planograms_20150112.bak'' 

WITH  FILE = 1 

,MOVE  N''Planograms'' TO N''H:\MSSQL\Data\planograms'+@name+'.mdf''

,MOVE N''Planograms_log'' TO N''H:\MSSQL\Data\planograms'+@name+'_1.ldf''

,  NOUNLOAD

,  STATS = 10

'

print @cmd

--exec (@cmd)

 

FETCH NEXT FROM @Cursor INTO @name

end

 

Similar Posts:

Метки:

Добавить комментарий