Fun with GO

Published 05 September 08 08:58 AM | Madhivanan 

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;

Filed under: , ,

Comments

# Other SQL Server Blogs around the Web said on September 5, 2008 4:58 AM:

In this blog post , I explained different uses of GO command Here is a Fun when you use GO as object

# SQL Server Transact-SQL (SSQA.net) : Fun with GO said on September 5, 2008 5:07 AM:

PingBack from http://sqlserver-qa.net/blogs/t-sql/archive/2008/09/05/4852.aspx

# Log Buffer #114: A Carnival of the Vanities for DBAs said on September 12, 2008 11:23 AM:

PingBack from http://www.pythian.com/blogs/1218/log-buffer-114-a-carnival-of-the-vanities-for-dbas

Anonymous comments are disabled