How to: Validate a Query without Executing

After you write a script or query, you can validate the Transact-SQL syntax before you execute the script or query. The validation examines the syntax of each Transact-SQL statement and returns any errors without compiling or executing the statement. For example, validation does not identify misspelled column or table names, but it would recognize if you misspelled SELECT in the SELECT clause.

Note

Validation occurs on the database server and requires a database connection. You will be prompted to connect to an instance of SQL Server if you attempt to validate while the query window is disconnected.

During the validation, the query is checked for correct Transact-SQL syntax. If an error is found, it appears on the Results tab of the results pane and in the Error List window. If no errors are found, the message "Command(s) completed successfully." appears.

For more information about how to execute your query after you validate it, see How to: Execute a Query.

For more information about how to start the editor, see How to: Start the Transact-SQL Editor.

To validate the syntax of your query from the Data menu

  1. Open the query in the Transact-SQL editor.

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

To validate the syntax of your query from the toolbar

  1. Open the query in the Transact-SQL editor.

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

To validate the syntax of your query from the shortcut menu

  1. Open the query in the Transact-SQL editor.

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

To validate the syntax of your query using the keyboard shortcut

  1. Open the query in the Transact-SQL editor.

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

See Also

Tasks

Walkthrough: Create and Execute a Simple Transact-SQL Script

Concepts

Editing Database Scripts and Objects with the Transact-SQL Editor