Learn more about SQL Server tools

mssqltips logo
 

Tutorials          DBA          Dev          BI          Career          Categories          Webcasts          Scripts          Today's Tip          Join

Tutorials      DBA      Dev      BI      Categories      Webcasts

DBA    Dev    BI    Categories

 

Building and Deploying a Database



By:

Overview

We have done all our up front work to prepare for our first deployment. We are now ready to actually create the database!

Explanation

Before we begin the build and deploy, let's make sure output is visible so we can the results of our actions.

We are now ready to actually create the database!

We choose Build DemoDB from Build.

We choose Build DemoDB from Build

The output window shows that we've built our project into a .dbschema file. This is an important file as it contains all the objects that make up our data model. It is used by the deployment process to compare against any existing database and to update the target database as needed. If the target database doesn't exist, naturally, the database is created with the defined objects.

The output window shows that we've built our project into a .dbschema file

Examining the file system, we see that Visual Studio built the following files:

Visual Studio built the following files

Now that the .dbschema file has been created, we can finally create the database! We choose Deploy DemoDB:

We choose Deploy DemoDB

The output shows that our objects have been created and our seed data populated. Note that Visual Studio kept track of object dependencies and ensured objects were created in the proper order. Also note that the post deployment script ran after the deployment occurred.

the post deployment script ran after the deployment occurred.

Let's re-examine the scripts in the file system. We now see a script file called DemoDB.sql has been produced by the deploy. This is the auto generated master .sql file I mentioned earlier that contains pre-deployment SQL, the deployment SQL of new/changed/dropped objects, and post deployment SQL. This script was executed against our SQL Server instance by Visual Studio.

This script was executed against our SQL Server instance by Visual Studio.

Examining SQL Server Management Studio, we see our database and it's objects have been created!!

Examining SQL Server Management Studio

Last Update: 9/10/2011




More SQL Server Solutions











Post a comment or let the author know this tip helped.

All comments are reviewed, so stay on subject or we may delete your comment. Note: your email address is not published. Required fields are marked with an asterisk (*).

*Name    *Email    Email me updates 


Signup for our newsletter
 I agree by submitting my data to receive communications, account updates and/or special offers about SQL Server from MSSQLTips and/or its Sponsors. I have read the privacy statement and understand I may unsubscribe at any time.



    



Learn more about SQL Server tools