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.
Note
Validation occurs on the database server.
To validate the syntax of your query from the Data menu
Open the query in the T-SQL editor. For information about how to start the editor, see How to: Start the Transact-SQL Editor.
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
Open the query in the T-SQL editor. For information about how to start the editor, see How to: Start the Transact-SQL Editor.
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
Open the query in the T-SQL editor. For information about how to start the editor, see How to: Start the Transact-SQL Editor.
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
Open the query in the T-SQL editor. For information about how to start the editor, see How to: Start the Transact-SQL Editor.
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.
See Also
Tasks
Walkthrough: Create and Execute a Simple Transact-SQL Script