/ Published in: SQL
I wrote that while working at CGI on Océ project in 2009-03. This script will help you migrate DB from one server to another. You have to use the source server to generate the script for the destination server.
Expand |
Embed | Plain Text
-- ATTACH / DETACH SELECT 'exec sp_detach_db '''+rtrim(name)+'''' FROM sysdatabases WHERE dbid > 4 -- Use script on source to attach on destination SELECT dbid*1000,name,'exec sp_attach_db '''+name+''',' FROM sysdatabases WHERE dbid > 4 union ALL SELECT dbid*1000+fileid,db_name(dbid), ','''+rtrim(filename)+'''' FROM sysaltfiles WHERE dbid > 4 ORDER BY 1
You need to login to post a comment.
