Please find the below sample code
drop table if exists #myTest
create table #myTest (
id int,
name varchar(30)
)
insert into #myTest values
(1, 'John'),
(2, 'Somu')
--select 1/0 -- Query 1 throws error
--select cast('ABC' as int) -- Query 2 throws error
insert into #myTest values
(3, 'Bela'),
(2, 'Steve')
select * from #myTest
When I uncomment 'Query 1' it throws below error but successfully inserts all 4 rows.
Msg 8134, Level 16, State 1, Line 62 Divide by zero error encountered.
When I uncomment 'Query 2' it throws below error but this time inserts no rows.
Msg 245, Level 16, State 1, Line 63 Conversion failed when converting the varchar value 'ABC' to data type int.
Looking at the error message it is not clear why one error allowed insertion of rows but second one did not. Could someone please explain what is the difference between the two?