adminbd

Записи по mssql,oracle,windows и linux

Have a Question?

If you have any question you can ask below or enter what you are looking for!

ресторинг 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

 

Leave a Reply

Your email address will not be published. Required fields are marked *

You can use these HTML tags and attributes <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>