Fun with GO

In this blog post, I explained different uses of GO command

Here is a Fun when you use GO as object name

CREATE PROCEDURE GO
(
    @I INT
)
AS
    SELECT @I AS number

Well. The procedure is created and let us try to execute

GO 2

What we see is

Command
(s) completed successfully

Becuase it becomes a syntax to execute a batch for two times

EXECUTE GO 2

Result is 2

Now see what the results are for the following

Execution 1
[GO] 2

Execution 2
[GO] 2
GO 2

Execution 3
[GO] 2
GO
EXECUTE GO 2
GO

Execution 4
[GO] 2
GO 2
GO 2

Execution 5
[GO] 2
GO
GO

Execution 6
EXECUTE GO 2
EXECUTE GO 2
GO 2

Execution 7
[GO] 2
GO
GO 2
GO 2
EXECUTE GO 2
GO
GO 2
GO 2
GO 2

Execution 8
GO;

Execution 9
GO;2

Execution 10
GO 2;

 

Published 05 September 2008 10:01 by Madhivanan
Filed under: , ,

Comments

# Another use of GO command in SQL Server 2005 - Madhivanan

Pingback from  Another use of GO command in SQL Server 2005 - Madhivanan

# Usage of Semicolons in SQL Server

10 November 2009 10:02 by Madhivanan

As you know, semicolon is used as a statement terminator in almost all RDBMSs. However the usage of semicolon

# Usage of Semicolons in SQL Server

10 November 2009 10:23 by SQL Server Transact-SQL (SSQA.net)

As you know, semicolon is used as a statement terminator in almost all RDBMSs. However the usage of semicolon