/ Published in: SQL
URL: migration, admin, codegenerator
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.
Expand |
Embed | Plain Text
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
Comments
Subscribe to comments
You need to login to post a comment.

hello
I need an example of a project including the source code for backup and restore of the database I used language delphi7 paradox database I used four table table1 = pers.db table2 = doc.db table4 = reng.db table3 = param.db