Wednesday, February 22, 2006

 

Comment on GO

/* */ is the one among the two commenting commands available in T-SQL Server which is used to comment a paragraph (block comment). The other – (double dash) is used to comment a line (commonly known as in-line comment).


Including GO command inside the block comment ( /* ….. */ ) invalidates the comment and generates an error. We can’t embed GO command within the block comments. If we want to do so, then we need to put an inline (--) command before the GO signal.


/*
select @@version
go
*/


The above block comment throws errors as:

Server: Msg 113, Level 15, State 1, Line 1
Missing end comment mark '*/'.
Server: Msg 170, Level 15, State 1, Line 1
Line 1: Incorrect syntax near '*'.


However, adding an inline comment before the GO signal makes SQL Server parser to treat the comments as comments.

/*
select @@version
--go
*/

Comments: Post a Comment

<< Home

This page is powered by Blogger. Isn't yours?