Link to home
Start Free TrialLog in
Avatar of newjeep19
newjeep19Flag for United States of America

asked on

How to transfer / copy a database from one server to another

I need to copy or transfer a database (tables, views, stored procedures, functions, etc.) from one database server to another. I tried using the wizard and the wizard did not copy over any of the tables, views, stored procedures, functions. I tried import / export function and only the tables were copied over from the old database to the new one.  I also tried to use generate scripts for views and stored procedures and I have the script to my desktop or another location but I don't know how to import the views or stored procedures from the scripts to the database.
Is the a SQL script or any other way that I can copy the entire database from one server to another server. Time is of the issue. So your help is greatly appreciated.
Thank you
Avatar of ste5an
ste5an
Flag of Germany image

The easiest way is to restore a backup on the second server.
Avatar of newjeep19

ASKER

Can you give me the steps? I have never done this before. Thanks
You can also take the help of this link to copy data between servers
https://technet.microsoft.com/en-us/library/ms190923(v=sql.105).aspx
Hi newjeep19,
I have 3 articles written about migrating databases. Each article talks about a method so you can choose the one that fits you more:
The Detach/Attach method
The Backup & Restore method
The Copy Database Wizard method
Thanks for sending me the links on the steps. I think that the backup and restore method is the best way to go about this. However, I am still on clear of how I can copy the full backup file from the source location backup path to the destination server. When I am on the destination server I go to Task-> Restore-> Restore Files and File groups and then click on the add button. However, their is no backup because the backup is on the source server and not the destination server. Thought? Examples? Thanks
However, I am still on clear of how I can copy the full backup file from the source location backup path to the destination server.
You can copy the file through the network from the source to the target server.

When I am on the destination server I go to Task-> Restore-> Restore Files and File groups and then click on the add button. However, their is no backup because the backup is on the source server and not the destination server.
This is because SSMS only works with drive letters. If you want to use a share you need to type it as \\SourceServerName\c$\BackupFolder\BackupFileName.bak

Other option is to use T-SQL to restore the backup as I also wrote in my article. Just replace the path with the correct network path:
RESTORE DATABASE [DatabaseNameHere] 
FROM  DISK = N'\\ServerName\Backup\DatabaseName.bak' 

Open in new window

OK  when I try using the SSMS method I get the below error:
User generated image
Change the name of the backup and try again - it will work.
You're trying to overwrite another database? If so you'll need to check the Overwrite option before running the Restore.
Thank you all for your assistance. I am able to due a full back up of multiple databases from your suggestions.
ASKER CERTIFIED SOLUTION
Avatar of Vitor Montalvão
Vitor Montalvão
Flag of Switzerland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks for all your help