I want to print a message ("The table employe is not exist in database") in my query.
My query is:
create proc sp_emprecord
as
begin
select * from employe
end
begin try
execute sp_emprecord
end try
begin catch
select
error_message() as errormessage,
error_number() as erronumber,
error_state() as errorstate,
error_procedure() as errorprocedure,
error_line() as errorline;
end catch
Try this:
create proc sp_emprecord
as
begin
select * from employe
end
go
begin try
execute sp_emprecord
end try
begin catch
if(ERROR_NUMBER() = 208)
RAISERROR ('The table employe is not exist in database', 0, 1) WITH NOWAIT;
else
select
error_message() as errormessage,
error_number() as erronumber,
error_state() as errorstate,
error_procedure() as errorprocedure,
error_line() as errorline;
end catch
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With