I know that in SQL Server GO is considered a batch separator.
My question is: What is the point of having a batch separator? What benef
Like Martain said, statements such as CREATE PROCEDURE must be the only ones in a batch.
For example, I use batch separators whenever I create stored procedures and add permissions to a certain user. If I left out the 'go' then I would end up with a stored procedure that grants rights every time it runs. This way I can write them at the same time and be sure that I'm not writing stored procedures that break when I call them. For example
create procedure [procedurename]
(parameters)
as begin
select prefname, lastname from people
end
go
grant execute on [procedurename] to [username]