When writing or modifying stored procedures, functions, or triggers, I often see developers get tripped up by strange compiler errors that have nothing to do with SQL itself and everything to do with improper batching.
“Incorrect syntax near ‘CREATE PROCEDURE’. Expecting ‘END’.”
If you check the image below, you’ll see that even though the procedures are valid, SSMS, Azure Data Studio, and sqlcmd treat this as one batch, because there’s no explicit separation.

GO is not T-SQL. It’s a batch separator interpreted by the client tool, not SQL Server. It tells the tool: “Send everything up to this point to the SQL engine for parsing/execution.”

Why is this important?
You can only have one CREATE PROCEDURE per batch. So Variable declarations, USE statements, and SET options reset with each GO.
Tips:
Use GO between DDL statements like CREATE, ALTER, and DROP.
Don’t use GO inside stored procedure bodies, T-SQL doesn’t allow that.
Be careful when scripting multiple procedures/functions; missing GO can silently corrupt your deployment scripts.