Very interesting question, can anybody what will be the answer if we execute this query by selecting all at once.
DECLARE @Test1 int, @Test2 VARCHAR(20)
SET @Test1 = 1;
SET @Test2 = 'Character';
SELECT @Test1,@Test2
GO
SELECT @Test1,@Test2
- Either it through an error
- Or Give 1 Character twice.
Yes – It will through error as @Test1 is undefined, because after GO it ends the scope of declaration of the variable.
Here we seen the scope of Variable declaring into SQL.
No comments:
Post a Comment