RSS

Update SQL Database Project Scripts from Database

16 Mar

If you create an empty SQL Database Project and if you already have an existing database with tables, stored procedures, etc. you can use following steps to create or update the SQL Database Project.

  • Open the Solution Explorer.
  • Right click on the SQL Server Project
  • Select Schema Compare

image

  • Click the Switch source and target button in the middle, to swap the DatabaseProject to the right.
  • Select left in where the source field is in the drop down menu Select Source.
  • In the window that opens insert all SQL Credentials of the database.
  • Then After inserting Click the Compare button to list all differences
  • If the Database Project is empty you will get a list of all objects of the database. But if the Database has only a few changes you get a list as the following:

image

  • As you can see, you will immediate get a overview about what has changed.
  • Now you can select the changes you want to update and click the Update button.
  • That’s all. You have successfully updated or created the Database Project. Now the Database and the Database Project has the same schema.

If you desire you can also do the reverse way and update your database with the changes made in the SQL Database Project. But I do not suggest to do that this way. You should do that by publishing the SQL Database Project to the SQL Server. Doing that you can provide a Pre- and Post-Deployment Script. In those script you  can integrate queries to migrate data during the deployment process.

Advertisements
 
Leave a comment

Posted by on March 16, 2012 in SQL, Visual Studio

 

Tags: ,

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: