In your example, the insert statement will ALWAYS be executed, since it is not evaluated as part of the IF statement.
Sample code for MS SQL Server:
Declare @a as int Declare @b as int Set @a = 2 If (@a > 1) Set @b = 1 + 2 Select 'Select Reached'
This is equivalent to writing:
Declare @a as int Declare @b as int Set @a = 2 If (@a > 1) BEGIN Set @b = 1 + 2 END Select 'Select Reached'
source share