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 2Now 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;