This documentation is archived and is not being maintained.

How to: Run SQL Scripts in Solution Explorer

You can run SQL scripts in Solution Explorer by dragging a script file to a database in the Database References folder. Another way to run SQL scripts is right-clicking the script and choosing either Run or Run On from the shortcut menu. When you choose Run, the SQL script runs on the default database. When you choose Run On, you can select which database to use.

Note   For a list of the SQL script file extensions you can use, see Working with Scripts.


Your computer might show different names or locations for some of the Visual Studio user interface elements in the following instructions. The Visual Studio edition that you have and the settings that you use determine these elements. For more information, see Visual Studio Settings.

To run an SQL script in Solution Explorer

  1. In Solution Explorer, drag an SQL script to a database reference. This could be a change, create, or query SQL script.

    The Execute Scripts or Queries dialog box appears.

  2. Click Yes to proceed with the script, or click No to avoid running the script.