Question of the month November 2016 – Why does semicolon followed by GO give error?

You know that specifying a number after GO statement will execute the above statement by as many number as specified in it.

Example

select 1
go 2

As you see you will get two result sets with value 1

But when you put semicolon after go 2

select 1
go 2;

You get the following error

A fatal scripting error occurred.
Incorrect syntax was encountered while parsing go.

Why does it give error?

Advertisement

One thought on “Question of the month November 2016 – Why does semicolon followed by GO give error?

  1. Semicolon denotes end of statement while Go is special statement in T SQL, which executes just above code block n times. where n denoted a number followed by GO statement.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s