Managing Queries in the Project Explorer

See Also   Tasks

The Project Explorer provides a graphical means of managing the queries in your database project. By double-clicking, dragging and dropping, and using the right-click features, you can open, create, edit, and execute your queries.

Note   In Microsoft Visual C++®, the Project Explorer is called FileView. From FileView, you can manage queries in much the same way as you can in the Project Explorer. For more information, see FileView in the Visual C++ documentation.

For details about using the Microsoft Visual Database Tools with database projects, see Working with Database Projects.

If you are working in a database project, you can perform the following tasks from the Project Explorer:

To add a query in the Project Explorer

  1. Expand the project name to show the names of all the data connections currently defined for your project.

  2. Right-click the data connection for the database you want to work with, and then choose Add Query from the shortcut menu.

Tip   You can also right-click the project name, and then select Add Item to open the Add Item dialog box.

  1. In the Add Item dialog box, choose Database Query.

  2. In the Name box, type in a name for the query, and then click Open.

    The Query Designer opens. For details about creating the query, see Creating Queries.

After creating the query in the Query Designer, you can save it. When you save a query:

To save a query

The Query Designer saves the SQL statement in a file, along with the window layout and any parameter information you have specified. By default, the query is saved in the project directory (the directory you specified when you created the database project), but you can specify any location available to your computer.

Note   Queries are not stored as part of the database that you are querying. Instead, they are stored as stand-alone files on your computer or on the network you are connected to.

After creating a query, you can run it or open it again for further editing. If you no longer need a query, you can also delete it from the project.

To run, edit, or delete a query in the Project Explorer

  1. Expand the project name to show the names of all the data connections currently defined for your database project, and then expand the data connection for the database you want to use.

  2. Right-click the query to work with, and then choose one of the following options.
    To Choose
    Edit the query Design
    Run the query Open (or double-click the name of the query)
    Delete the query Delete
    Rename the query Rename