Run, view, or edit an SQL command, procedure, or statement

Microsoft Query

Show All Show All

Run, view, or edit an SQL command, procedure, or statement

If you know Structured Query Language (SQL), you can use SQL to edit a query's SQL SELECT statement. For more information about SQL, see the documentation for your database.

  1. Create a new query. Do not return the results to Microsoft Excel.

    How?

  2. Click View SQL Button image.

    Microsoft Query displays the SQL dialog box with the SQL SELECT statement that corresponds to the query.

  3. Type any changes you want to make into the SQL statement, and then click OK.

    To add a new line in the SQL statement box, press ENTER.

Notes

  • To change or replace the SQL statement, use the same SQL syntax that Microsoft Query uses or the syntax your data source supports. Microsoft Query tries to interpret the syntax you use and displays both the query's design and its result set.
  • If Microsoft Query can't display the query's design because it can't interpret a portion of the syntax you used, the result set is still displayed. However, you can change only the result set's formatting, such as the display font or column width. You can't edit data, and you must make any change to the query definition, such as adding or removing fields, in the SQL dialog box.