Revision: 13269
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at April 16, 2009 22:30 by pollusb
Initial Code
xp_cmdshell 'NET USE T: \\10.106.68.110\w578-db-zip /user:cacpx-platespin\pollus password' xp_cmdshell 'DIR T:\2009-04-14\BMSQL\*.bak' --SNIPPET:Use a 1 file backup folder to generate RESTORE DATABASE commands create table #dir(filename varchar(1000)) insert into #dir exec master..xp_cmdshell 'DIR T:\2009-04-14\BMSQL\*.bak /b' delete from #dir where filename is null select * from #dir select 'RESTORE DATABASE ['+replace(filename,'.BAK','')+'] FROM DISK = ''T:\2009-04-14\BMSQL\' +filename+''' WITH REPLACE,NORECOVERY,STATS = 10;' from #dir where filename not in('master.bak','msdb.bak') --drop table #dir
Initial URL
migration, admin, codegenerator
Initial Description
Use a file list to generate a RESTORE script. You may want to review the WITH option. This script is for advanced user only. Works only with 1 file per database backup.
Initial Title
RESTORE DATABASE from a list of files
Initial Tags
Initial Language
SQL