What Happens to a Statement Batch If There Is a Compilation Error?

Submitted by: Administrator
If a statement batch has multiple statements, and one of them has compilation error, all statements in the batch will not be executed. The tutorial exercise below gives you some good examples:

SELECT getdate();
SELECT getdates();
SELECT getdate();
GO
Msg 195, Level 15, State 10, Line 2
'getdates' is not a recognized built-in function name.

As you can see, the compilation error on the second statement stops the execution of all statements.
Submitted by: Administrator

Read Online MS SQL Server Job Interview Questions And Answers