declare Usage


IF 1=1 BEGIN DECLARE @test VARCHAR SET @test='1' PRINT 'in if:'+@test END GO PRINT 'out if:'+@test IF 1=1 BEGIN DECLARE @test VARCHAR SET @test='1' PRINT 'in if:'+@test END PRINT 'out if:'+@test
After comparison, we can see
Scope declare a variable is a batch where, if not blocking its scope, that the above code if we value both inside and outside of the code in a batch, so @test are available and if they contain also in.
GO is the end for a sql statement
 

 

Guess you like

Origin www.cnblogs.com/shanshuiYiCheng/p/11542192.html