Currently, SQL server supports the following statements: SET NOEXEC and SET PARSEONLY.
From the documentation:
SET NOEXEC ON:
When SET NOEXEC is ON, SQL Server compiles each batch of Transact-SQL statements but does not execute them.
SET PARSEONLY ON:
When SET PARSEONLY is ON, SQL Server only parses the statement.
I guess it's "compiles" vs. "parses". "Compiles" should include "parses".
If I want to verify the correctness of SQL Scripts which one should I use? I am inclined to answer: SET NOEXEC ON
.
But what else does compile do? Does "compile" mean the execution plans are created/modified? Is the existence of objects checked?
What happens if you have:
SET NOEXEC ON
SET PARSEONLY OFF
I find having both options available confusing.
Thanks
Best Answer
There are three steps to running a batch:
PARSEONLY stops after step 1). NOEXEC stops after step 2), with the exception that NOEXEC supports deferred name resolution and won't fail if the target tables don't exist.
NOEXEC
PARSEONLY