Why is variable declared inside IF statement created even when condition evaluates to false?
- by AspOnMyNet
Since @A is never declared, sql server should throw an error, but it doesn’t. Why is that?
DECLARE @i int = 1;
IF @i > 10
BEGIN
DECLARE @A int = 100;
END
PRINT @A; // doesn't return any result
thanx