Of the four select statements in the following script, I would expect the second and third statements to execute and the first and fourth not to execute. The first does not, but the fourth does. It seems the conditional does not apply to SET NOEXEC OFF
.
SET NOEXEC OFF
IF (1 = 1) SET NOEXEC ON
SELECT 'Should not see this'
GO
SET NOEXEC OFF
IF (1 = 2) SET NOEXEC ON
SELECT 'Should see this'
GO
SET NOEXEC ON
IF (1 = 1) SET NOEXEC OFF
SELECT 'Should see this'
GO
SET NOEXEC ON
IF (1 = 2) SET NOEXEC OFF
SELECT 'Should not see this, but you do!'
GO