In case you didn’t already know, you can run SQL scripts right within Visual Studio.NET which is much nicer than having to fire-up Query Analyzer all of the time. This tutorial assumes you already know what a Database project is in Visual Studio.
Instructions:
The first thing you must do is create a Database Reference in your database project. In the Visual Studio Solution Explorer, open the database project and right click on the Database References folder. Select New Database Reference… and the following window should pop-up:

If the database you’d like to connect to is not listed, click Add New Reference… and you will be prompted to setup a connection to the database of your choice. Items are added to this list via the Server Explorer.
You can add several database references to a project. I would suggest making a reference to your local, development SQL database and one to the live web server’s SQL database.
Once the database you’d like to connect to is listed in the Add Database Reference list, select it and click OK. You notice that this reference is now listed under the Database Reference section in the Solution Explorer:

If you have several databases listed, you can right-click on the one you want as the default (usually your local SQL database) and select Set as Project Default.
To run a SQL Script against a selected database, right-click one of the SQL scripts stored in the database project and select Run On… You’ll be prompted with a window like this:

Select the database you’d like to run the script against, click OK, and the script runs! Hopefully you’ll find this a useful and time-saving tip J