Show AllShow All

Execute an SQL statement or procedure

If you know Structured Query Language (SQL), you can use SQL to execute an SQL SELECT statement. For more information about SQL, see the documentation for your database.

  1. On the File menu, click Execute SQL.

    To execute an SQL statement on a table in another data source, click Data Sources, click the data source you want, and then click OK. You can specify a new data source.

    How?

  2. In the SQL statement box, type the SQL statement you want to run.

    If you have an existing SQL statement you want to run, click Open, click the SQL file, and then click Open.

    To run an SQL procedure stored in your external database, click Procedures, click the procedure you want in the Query box, and then click Paste to copy the procedure to the SQL statement box.

  3. Click Execute.

    Microsoft Query runs the SQL statement. If the query is taking a long time to return data, you can cancel the query by pressing ESC.

    To save the SQL statement, click Save.

Notes