Why is variable declared inside IF statement created even when condition evaluates to false?
Posted
by AspOnMyNet
on Stack Overflow
See other posts from Stack Overflow
or by AspOnMyNet
Published on 2010-06-01T19:14:43Z
Indexed on
2010/06/02
4:33 UTC
Read the original article
Hit count: 236
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
© Stack Overflow or respective owner