i m new in sql.i want print a message(the table employe is not exist in database) in error handling with try and catch
-
my query is
<pre lang="SQL">create proc sp_emprecord
as begin
select * from employe
end
begin try
execute sp_emprecord
end trybegin catch select error\_message() as errormessage, error\_number() as erronumber, error\_state() as errorstate, error\_procedure() as errorprocedure, error\_line() as errorline; end catch</pre>
-
my query is
<pre lang="SQL">create proc sp_emprecord
as begin
select * from employe
end
begin try
execute sp_emprecord
end trybegin catch select error\_message() as errormessage, error\_number() as erronumber, error\_state() as errorstate, error\_procedure() as errorprocedure, error\_line() as errorline; end catch</pre>
You have already asked this vague question in QA
Why is common sense not common? Never argue with an idiot. They will drag you down to their level where they are an expert. Sometimes it takes a lot of work to be lazy Please stand in front of my pistol, smile and wait for the flash - JSOP 2012
-
my query is
<pre lang="SQL">create proc sp_emprecord
as begin
select * from employe
end
begin try
execute sp_emprecord
end trybegin catch select error\_message() as errormessage, error\_number() as erronumber, error\_state() as errorstate, error\_procedure() as errorprocedure, error\_line() as errorline; end catch</pre>
-
my query is
<pre lang="SQL">create proc sp_emprecord
as begin
select * from employe
end
begin try
execute sp_emprecord
end trybegin catch select error\_message() as errormessage, error\_number() as erronumber, error\_state() as errorstate, error\_procedure() as errorprocedure, error\_line() as errorline; end catch</pre>
That's probably not worth the effort; just catch the Exception in the calling code. And don't prefix your procedures with
sp_
-- that's for System Procedures.