What is the difference between ;
and GO
in stored procedure in SQL Server ?
Actually, if I have a stored procedure in SQL server and wanna to p
The semicolon separates queries, the GO command separates batches. (Also GO is not a T-SQL command, it's a command recognised by the sqlcmd and osql utilities and Management Studio.)
You can't use GO inside a stored procedure. If you would try, the definition of the procedure will end there, and the rest will be a separate batch.
A local variable has the scope of the batch, so after a GO command you can't use local variables declared before the GO command:
declare @test int
set @test = 42
GO
select @Test -- causes an error message as @Test is undefined