Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I validate SQL syntax in SQL Server 2008 R2?

Is there the option to check syntax after I have completed create a query? If so, where can I find it? What does it validate and what does it not validate?

like image 663
PeanutsMonkey Avatar asked Feb 19 '12 19:02

PeanutsMonkey


People also ask

How do you validate a SQL query?

To validate the syntax of the statements, right-click in the editor, and then select a validation option. To validate the syntax of the statements for the connection that is selected in the Configuration tab, select the Validate statement syntax for current configuration option.

How can I tell what SQL features are installed?

Run SQL Server features discovery report To run the SQL Server features discovery report, click Tools in the left-hand navigation area of SQL Server Installation Center, and then click Installed SQL Server features discovery report.

How do I check if a SQL query is running?

You can view this by Right Clicking on Instance Name in SQL Server Management Studio and selecting “Activity Monitor”. Activity monitor tells you what the current and recent activities are in your SQL Server Instance. The above screenshot displays an overview window for the Activity Monitor.


1 Answers

SET FMTONLY  ON 
--Your Query Here

This will validate your objects as well. It will give you the error if you do not have that object present in your database. It will not execute your Query on the database but only parse it and validate syntax and objects.

like image 86
Trupti J Avatar answered Oct 27 '22 16:10

Trupti J