How to migrate a database from on prem SQL Server to SQL Server in VM

Fred Luk 1 Reputation point
2020-11-19T23:26:55.467+00:00

I have several databases on a SQL Server running on premises. How can I migrate one particular database from my SQL Server to SQL Server running on a VM ? I want to migrate the data as well as all the stored procedures.

My problem is that my SQL Server on VM uses Windows authentication with a different user name than the PC that I run my on-prem SQL Server management studio. So, I cannot use the COPY Database facility as describe in the following link.

https://www.c-sharpcorner.com/UploadFile/4b43b4/copy-database-from-one-server-to-another-server-in-sql/

Thanks in advance,
Fred

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
13,786 questions
{count} votes

5 answers

Sort by: Most helpful
  1. Dirk Hondong 871 Reputation points
    2020-11-21T13:13:29.1+00:00

    Hi anonymous userLuk-9638 ,

    so, to recap: you have a local PC with SQL Server and you want to move one particular DB to a new SQL server which resides in a VM.
    If you only want to move the database, then just do a backup of the database to your local file system.
    Grab the database dump afterwards, copy it to your vm or a network share, which is accessible.
    Then run a restore.

    Much simpler than using the copy database wizard.

    1 person found this answer helpful.
    0 comments No comments

  2. Fred Luk 1 Reputation point
    2020-11-19T23:49:47.467+00:00

    41137-sqlservervmerr.png

    This is the screenshot that shows the error when I tried to connect to the remote SQL Server on VM.


  3. Chandresh Awasthi 1 Reputation point Microsoft Employee
    2020-11-20T00:04:36.51+00:00

    You can either create a SQL credential on your on-premise DB and login using that on your restored SQL DB on the VM, but, better option would be to have your windows ID federated with Azure AD and then using the AD credentials on the cloud version.


  4. Fred Luk 1 Reputation point
    2020-11-21T07:11:49.763+00:00

    Hi Chandresh, Thank you for your reply. Can you explain how to do the first approach ? I am not familiar with Azure AD so that would take more effort to set up. I log into the SQL Server on my VM with server name: cocetlvbraquyd4 and username: cocetlvbraquyd4\qb and no password.

    Thanks in advance,
    Fred

    0 comments No comments

  5. Fred Luk 1 Reputation point
    2020-11-22T04:56:26.763+00:00

    Hi Dirk, Thanks for your reply. So will the store procedures be copied as well ? I guess I will give it a try.

    Many thanks,
    Fred


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.