I often get this question in the email – more frequently than I would like to get. Let us see a simple question about GO T-SQL Statement or not.
Question: “Is GO T-SQL statement?”
Answer: “No, GO is not a T-SQL statement, it is a command which is recognized by SSMS or sqlcmd as a signal to send the current batch to SQL Server Engine.”
Well, here are two articles I recommend to read for more information – MSDN and Explanation SQL Command GO.
Here are few things I would like to add related to the GO statement.
- If recommend a statement terminator semicolon after each statement, however, do not use semicolon after the GO statement or it will give an error.
- ODBC or OLE DB API does not recognize the GO statement and it will give a syntax error.
- You can use GO in a next line of T-SQL Statement. If you provide an integer after GO statement, it will execute that statement multiple times.
- You can only have comments in the same line as a GO statement, any other statement will error.
- You can change the command GO to any other value in SSMS by going to Tools > Option
Let me know your thoughts about the GO statement.
Reference: Pinal Dave (https://blog.sqlauthority.com)
13 Comments. Leave new
Hi,
Thanks.I was not knowing so much about GO, specially ..”You can change the command GO to any other value in SSMS by going to Tools > Option”
You can set it as “Run”
What if I set it as “Sir Rajni Kant” ?I think no need of writing query then,everythnig will be automatically handle.
OMG! that is very innovative thinking.
Nice… Change change to any other value…new for me !!!
We all are leaning in this world.
Hi Pinal,
Thank you… New thing. :)
Thanks VAIBHAV !
Really very nice…
Thanks Aaditya.
Hi Pinal, I have tried changing the GO statement to something else..But its not working for me. I have changed value from Tools->Options. Is there something I am missing. Plz help.
Hi Pinal,
SELECT 1 GO ;
the above statement is working fine for me , it is not throwing any error when running above statement.
Yeah, it works fine.