declare @table table (i int not NULL, c varchar(100))
insert into @table values ('a','1')
if (@@error <> 0)
print (' caught error.. ')
output ..
Server: Msg 245, Level 16, State 1, Line 3
Syntax error converting the varchar value 'a' to a column of data type int.
As you can see, I try to catch that error, but my debug statement does not print out. the query terminates before getting there. I want to catch that error.. anyone know how? is it even possible?
If i try to insert a NULL value and try to catch the error, it prints out my debug statement fine, but I cant seem to catch that syntax error..
Thanks,
insert into @table values ('a','1')
if (@@error <> 0)
print (' caught error.. ')
output ..
Server: Msg 245, Level 16, State 1, Line 3
Syntax error converting the varchar value 'a' to a column of data type int.
As you can see, I try to catch that error, but my debug statement does not print out. the query terminates before getting there. I want to catch that error.. anyone know how? is it even possible?
If i try to insert a NULL value and try to catch the error, it prints out my debug statement fine, but I cant seem to catch that syntax error..
Thanks,