sqlsql-serversql-server-2016

What is the best way to migrate one database from one server to another in SQL Server with the keys?


I am trying to migrate or Copy one database from one server to another server. Here is what I have tried so far:

  1. I used the SQL Server wizard to Migrate (Under the tasks) and it works fine except that I did not see an option to move the PKs and FKs with that . (Please let me know If I could do it)
  2. I tried to generate the Script with PKs and FKs but the file size is around 10GB. Because the file is too large I use "sqlcmd -S <server> -i C:\<your file here>.sql " in CMD but it does not show the process.

So my question is, What is the best way to migrate or copy the database to another server with the Keys?


Solution

    1. Backup the database on server 1.
    2. Move the backup file to server 2.
    3. Restore the database on server 2.