Validating an SQL query programmatically, with gotcha
If you want to check the validity of a TSQL statement programmatically, you can make use of the SET NOEXEC statement. As this MSDN reference states, SET NOEXEC ON will compile the query but won’t actually execute it. This is ideal (well, nearly….) if perhaps you have a dynamically generated statement that you want to check is valid before executing it.
Example time SET NOEXEC ON GO SELECT TOP * FROM sys.
[Read More]