Total Pageviews

SET NOEXEC ON in SQL SERVER

It compiles each query but does not execute it.
Suppose we have a big SQL script with a ton of code and we want to make sure it runs but you don't want to execute it because it updates tables, deletes data etc.
The execution of statements in SQL Server has two phases: compilation and execution.
This setting is useful for having SQL Server validate the syntax and object names in Transact-SQL code when executing. It is also useful for debugging statements that would generally be part of a larger batch of statements.
The setting of SET NOEXEC is set at execution or run time and not at parse time.
E.g.
SET NOEXEC ON;
SELECT GETDATE()
GO

++++++++++++++++++++++
++++++++++++++++++++++

SET NOEXEC OFF;
SELECT GETDATE()
GO
++++++++++++++++++++++
++++++++++++++++++++++




No comments:

Post a Comment