How to: Validate a Query without Executing

After you write a script or query, you can validate the Transact-SQL (T-SQL) syntax before you execute the script or query. The validation examines the syntax of each T-SQL statement and returns any errors without compiling or executing the statement. For example, this validation does not identify misspelled column or table names.

NoteNote:

Validation occurs on the database server.

To validate the syntax of your query from the Data menu

  1. Open the query in the T-SQL editor. For information about how to start the editor, see How to: Start the Transact-SQL Editor.

  2. On the Data menu, point to T-SQL Editor, and click Validate SQL Syntax.

    The query is checked for correct SQL syntax. This validation requires a database connection, and you cannot run it while the editor session is disconnected. If an error is found, it appears on the Messages tab of the results pane and in the Error List window. If no errors are found, the message "The SQL syntax is valid." appears.

    If you want to execute your query after you validate it, see How to: Execute a Query.

To validate the syntax of your query from the toolbar

  1. Open the query in the T-SQL editor. For information about how to start the editor, see How to: Start the Transact-SQL Editor.

  2. On the Transact-SQL toolbar, click Validate SQL Syntax.

    The query is checked for correct SQL syntax. This validation requires a database connection, and you cannot run it while the editor session is disconnected. If an error is found, it appears on the Messages tab of the results pane and in the Error List window. If no errors are found, the message "The SQL syntax is valid." appears.

    If you want to execute your query after you validate it, see How to: Execute a Query.

To validate the syntax of your query from the shortcut menu

  1. Open the query in the T-SQL editor. For information about how to start the editor, see How to: Start the Transact-SQL Editor.

  2. Right-click anywhere in the editor window, and then click Validate SQL Syntax.

    The query is checked for correct SQL syntax. This validation requires a database connection, and you cannot run it while the editor session is disconnected. If an error is found, it appears on the Messages tab of the results pane and in the Error List window. If no errors are found, the message "The SQL syntax is valid." appears

    If you want to execute your query after you validate it, see How to: Execute a Query.

To validate the syntax of your query using the keyboard shortcut

  1. Open the query in the T-SQL editor. For information about how to start the editor, see How to: Start the Transact-SQL Editor.

  2. Right-click anywhere in the editor window, and then press CTRL+F5.

    The query is checked for correct SQL syntax. This validation requires a database connection, and you cannot run it while the editor session is disconnected. If an error is found, it appears on the Messages tab of the results pane and in the Error List window. If no errors are found, the message "The SQL syntax is valid." appears

    If you want to execute your query after you validate it, see How to: Execute a Query.

Community Additions

ADD
Show: