I know that GO is used in SQL to terminate a batch and to control things like
ALTER TABLE tableName ADD name VARCHAR(20)
GO -- this GO will make sure that "name" will be added before the select statement
SELECT name FROM tableName
But can GO also be used to prevent delay problems? An example
DECLARE @countID int
SELECT @countID = COUNT(id) FROM Usuer -- this table has milions of registers and takes a while to be executed
--GO
SELECT @countID, Name FROM Something
SQL Server already wait for the first select to finish and then start the second select, or should I put the GO between the two statements to guarantee that the second select will be executed only after the first one?
thanks
GObetween them.GOis used in SQL Server Management Studio to terminate a batch. It is not part of the SQL language (neither standard SQL nor T-SQL).