How can I run a SQL script within Visual Studio?
To run SQL scripts within Visual Studio, you must first create a Database project. To do this, launch the New Project dialog and select Other Project Types | Database in the Project types pane, and select Database project in the Templates pane:

After adding a script to the project, you can run the script by dragging and dropping it on a database in the Database References folder:

You can also run a SQL script by right-clicking the script in the Solution Explorer and choosing Run or Run On from the shortcut menu. Choosing Run causes the SQL script to run on the default database. Choosing Run On displays a dialog allowing you to select the database to run the script on.
© (c) 2026 Oak Leaf Enterprises, Inc., 1996-2026 • Updated: 11/28/05
Comment or report problem with topic
