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
newjeep19Asked:
Who is Participating?
 
Vitor MontalvãoConnect With a Mentor MSSQL Senior EngineerCommented:
Great.
If your issue has been solved please choose one or more comments that helped you so this question can be properly closed.
Cheers
1
 
ste5anSenior DeveloperCommented:
The easiest way is to restore a backup on the second server.
0
 
newjeep19Author Commented:
Can you give me the steps? I have never done this before. Thanks
0
Improve Your Query Performance Tuning

In this FREE six-day email course, you'll learn from Janis Griffin, Database Performance Evangelist. She'll teach 12 steps that you can use to optimize your queries as much as possible and see measurable results in your work. Get started today!

 
ZberteocCommented:
0
 
Daniel JonesData Research AnalystCommented:
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
0
 
Vitor MontalvãoMSSQL Senior EngineerCommented:
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
0
 
newjeep19Author Commented:
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
0
 
Vitor MontalvãoMSSQL Senior EngineerCommented:
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

0
 
newjeep19Author Commented:
OK  when I try using the SSMS method I get the below error:
ErrorMEssage.png
0
 
Pawan KumarDatabase ExpertCommented:
Change the name of the backup and try again - it will work.
0
 
Vitor MontalvãoMSSQL Senior EngineerCommented:
You're trying to overwrite another database? If so you'll need to check the Overwrite option before running the Restore.
0
 
newjeep19Author Commented:
Thank you all for your assistance. I am able to due a full back up of multiple databases from your suggestions.
0
 
newjeep19Author Commented:
Thanks for all your help
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.