SET PARSEONLY#
Checks the syntax of each Transact-SQL batch and returns any syntax error messages without compiling or
executing the statements. Query tools use it to validate scripts without running them: the Parse button
(Ctrl+F5) in SQL Server Management Studio and SMO’s ExecutionTypes.ParseOnly both send
SET PARSEONLY ON, then the batches to check, then SET PARSEONLY OFF.
Syntax#
SET PARSEONLY { ON | OFF } [;]
Remarks#
SET PARSEONLY is applied at parse time, not at execution time: the toggle takes effect at the
point in the batch text where it appears, and the batch is executed only if the setting is OFF when
parsing of that batch completes. While ON, batches are only syntax-checked — object names are not
resolved, and no result sets, messages, or errors other than syntax errors are returned.
Dynamic SQL is parsed in a child scope. A SET PARSEONLY inside EXEC or sp_executesql
controls that dynamic batch, including whether the batch executes, but does not change the caller’s
setting. The child scope inherits the caller’s current value.
SQL Server rejects SET PARSEONLY inside a stored procedure, function, or trigger definition.
Permissions#
Requires membership in the public role.
Examples#
SET PARSEONLY ON;
GO
-- Syntax-checked only: not executed, and object names are not resolved.
SELECT * FROM crm.dbo.customers WHERE region = 'EU';
GO
SET PARSEONLY OFF;
GO