Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in SQL by (20.3k points)

I’ve always been confused with when I should use the GO keyword after commands and whether a semi-colon is required at the end of commands. What are the differences and why/when I should use them?

When I run the Generate-script in SQL Server Management Studio, it seems to use GO all over the place, but not the semi-colon.

1 Answer

0 votes
by (40.7k points)

Here, GO only relates to SSMS - it isn't actual Transact SQL, it just tells SSMS to send the SQL statements between each GO in individual batches sequentially.

And the; is a SQL statement delimiter, but for the most part, the engine can interpret where your statements are broken up.

The main exception, and place where the; is used most often is before a Common Table Expression Statement.

Related questions

Browse Categories

...