Error handling in SQL Server
Thank u. How can we check errors in sql. I tried doing the below:
begin try
begin transaction
execute........
commit transaction
end try
begin catch
select error_message();
end catch;
But it threw only errors like if a column is defined as not null and while inserting values into table, if that particular column is given null it threw error. But it does not check for anything else. If the data type is smalldatetime and date format while inserting is something else it did not throw error. The code show throw all the possible errors present in a script. How do we get it? Is it possible?
Thanks,
Saran.