Script to copy database between servers

The answer from Spike here was very nearly exactly what we needed. The only hurdle is how to have the backup run on one server and the restore run on another through linked server all in one script? It must be a script that can be turned into a stored procedure that's fed only source and destination DB names.

Does it present a problem that the source server is SQL Server Express 2012 whereas the destination is the full version?

It has to be a script that can run against any DB by just changing the DB name and logical names. It's for a process that's need to run very regularly and fully automatically against a different DB each time.

Also, why wouldn't be better to just detach, copy the mdf and ldf, then re-attach?

Answers


I'd suggest right clicking on the database in Management Studio, clicking Tasks then Generate Scripts.

You can script your entire database (make sure in advanced options you select to script both schema and data) and restore it on the other database.

You can also backup from one instance and onto another but bear in mind this may have issues if you're moving between versions.

Transfering LDF/MDF files is possible but in my opinion is difficult and high risk.


You can copy a database from one server to another, just follow those steps (SQL Server 2008): 1.Select the database in the source server in SSMS. 2.Right click ->Tasks->Copy Database Wizard to launch the copy database wizard. Enter the source and destination credentials and select either attach/detach or SMO type click next and you can schedule or run immediately, Click finish.

For your reference:

http://msdn.microsoft.com/en-us/library/ms188664.aspx


Need Your Help

Parameter value [0] did not match expected type [java.lang.Integer]

java spring jpa stored-procedures hql

Fun issue where I'm passing an int in and it's complaining about it not matching the type:

RGB-frame encoding - FFmpeg/libav

video encoding ffmpeg video-encoding libavcodec

I am learning video encoding & decoding in FFmpeg. I tried the code sample on this page (only the video encoding & decoding part). Here the dummy image being created is in YCbCr format. How...