Sql If Block Code Causing Error Even Though It Shouldn't Execute
I have a case in which I have SQL code with an IF-ELSE block. The code in the IF portion should not be reached, but I still get an error when the SQL executes. In the code I first
Solution 1:
It'll still parse and bind everything before it executes it. It's failing to bind here.
You could use sp_executesql to execute that line, and it should only validate when sp_executesql is actually called.
Post a Comment for "Sql If Block Code Causing Error Even Though It Shouldn't Execute"