mesut
mesut

Reputation: 2177

How to export the localDb to an online Sql Server Database?

I used visual studio 2013 for developing a web application and used a localDB in development phase, now I want to go to production phase and want to export the sql server localDb to the online SQL server database, but I cannot find any option to script out the localDb or migrate it?

Which tools I can use to do this ? or what I must do?

Upvotes: 4

Views: 9034

Answers (3)

Siddhant Rimal
Siddhant Rimal

Reputation: 978

There are atleast two routes; you could publish and recover as Data Tier Application: enter image description here enter image description here

Or, the easier-but-lengthier route would be to:

  1. Create a new DB in the SQL Server Management Studio (Naming it the same as LocalDB is helpful if you just want to change the connection string later) enter image description here
  2. Right-click database on SQL Server Object Explorer and select Schema Compare
  3. Click Select Target and navigate through Select Target Schema(Dialog) > Database > Click on Select Connection > Connect(Dialog) > Browse > Local > Database Name > Select the Databse you created in Step-1. Then, click OK
  4. Click Compare or, hit Shift+Alt+C
  5. Then, the Schema Comparator tells you whats different between the two databases (the one from MSSqlLocalDB and the one you just created in Step-1). It is important to remember unchecking ANY entries for delete operations, if you are simply transferring data and schema. Keep add operations as it is.
  6. Then, click on ↑UPDATE (the option is located right beside Compare)
  7. Your Target database should be updated enter image description here

Upvotes: 4

mesut
mesut

Reputation: 2177

Unfortunately VS2013 does not has any feature to script out a localDb, I waste so many time to copy table by table scripts, and run it at remote db. my local db id sql v11.0 (2012 I think). and the remote db was sql server 2008. so one way exist is to install an instance of sql server 2012 and sql server management studio to script out my db. maybe another tools also exist it is very sad that vs has not this feature.

Upvotes: 0

Ondipuli
Ondipuli

Reputation: 468

You can attach the localDb to SQLServer 2005 or higher and then you can generate scripts or export data to remote server. Or If LocalDb is SQL Server 2012, use SSMS 2012 or later for this scripting task.

Upvotes: 2

Related Questions