For list1, select ‘ok’ will be run even select 1/0 generate an error. for list 2 select ‘ok’ will not be run since update fail. Both list generate error of level 16 but why there are such difference?
--1
select 1/0
select 'ok'
--2
create table #t (a int)
insert into #t values(1)
update #t set b = 99
select 'ok'
update #t set b = 99is a compile time error.The batch is compiled and as
#tdoes not exist that statement is subject to a deferred compile. It is impossible to even generate a plan for this statement to update a non existent column so there is a compile error on that statement.Runtime compile errors abort the scope.
It is not always intuitive what effect a runtime error will have (abort the statement, scope, batch or connection). See What Happens when an Error Occurs? for some examples.