Share via


Running Queries

When you have finished designing your query, you can start the query by choosing the Run button. Visual FoxPro executes the SQL select statement you built with the Query Designer, and sends the results to a Browse window.

To run a query

  • In the Project Manager, select the name of the query, then choose Run.

If you want your results to go to a different destination, you can direct your results to a form, table, report, or other destinations. If you like to know what the SQL statement looks like, you can view the SQL statement that you built.

For more information, see SELECT - SQL.

Directing the Results of Your Query

You can send the results of your query to different destinations. If you have not selected an output destination, the results of your query will be shown in a Browse window.

When you choose Query Destination on the Query menu, or choose the Query Destination button on the Query toolbar, the Destination dialog box displays, so you can choose where to send your query results.

To choose a query destination

  1. From the Query Designer toolbar, choose Query Destination.
  2. In the Query Destination dialog box, choose an output destination, and fill out any additional fields as required.

Use this table to choose the destination for your query output.

If you want to Choose this output option
Display the results of your query in a Browse window Browse
Save the results of your query in a temporary read-only table with the name you assign it Cursor
Save the results of your query as a table with the name you assign it Table
Make the query results available for use with Microsoft Graph, a separate application included with Visual FoxPro Graph
Display the results of your query in the main Visual FoxPro window, or in the currently active output window Screen
Send the output to a report file (.frx) Report
Sends the output to a label file (.lbx) Label

Many of the options have additional choices you can make to affect the results. For example, the Report option lets you open a report file and customize the report before printing, or you can choose a Report Wizard to help you create the report. For more information, see Adding Reports and Labels.

Verifying Your Query

If you want to make sure the query is properly defined, you can view the SQL statement built by the Query Designer. Also, you can add comments to the query describing its purpose. The comments you add appear in the SQL window.

Viewing Your SQL Statement

At any time while you are creating your query, you can see the SQL statement your query is building by choosing View SQL from the Query menu or by choosing the SQL button on the toolbar.

A read-only window displays the SQL statement. You can copy the text in the window and paste it into the Command window or incorporate it into a program.

To see the SQL statement for your query

  • In the Query Designer toolbar, choose the SQL button.

Adding a Comment to Your Query

If you want to identify your query in some manner, or add notes about it, you can add comments to your query that will help identify it and its purpose.

To add a comment to a query

  1. From the Query menu, choose Comments.
  2. In the Comment box, type any notes you want to make about the query.
  3. Choose OK.

Comments you enter appear at the top of the SQL window, preceded by an asterisk.

See Also

Organizing Results | Customizing Queries | Browse window | SELECT - SQL | Destination dialog box | Querying Multiple Tables and Views | Updating Data in a View | Creating Queries