Interview Question of the Week #009 – Is GO T-SQL Statement?

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.”

Solarwinds

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.
    Interview Question of the Week #009 - Is GO T-SQL Statement? gostatement1
  • 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
    Interview Question of the Week #009 - Is GO T-SQL Statement? gostatement2

Let me know your thoughts about the GO statement.

Reference: Pinal Dave (https://blog.sqlauthority.com)

Solarwinds
, ,
Previous Post
Interview Question of the Week #008 – Write Scripts to Convert String to Title Case or Proper Case
Next Post
Interview Question of the Week #010 – What is the Difference Between Primary Key Constraints and Unique Key Constraints?

Related Posts

13 Comments. Leave new

Leave a Reply

Menu