Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Supress error message

Author  Topic 

vaidyanathanpc
Starting Member

24 Posts

Posted - 2002-04-10 : 08:33:05
Hi,
I have written a procedure to send mail.

CREATE procedure PCWishes
as
declare @rc int
Begin
exec @rc = master.dbo.xp_sendmail @recipients='Murali_K', @Subject='Service Anniversary!!',@Message='Hello'
if @rc = 1
begin
print 'Error'
end
End


The mail id given in the recepients list is an invalid mail id. When I execute this procedure from the query analyzer, I get the the following error message.

Server: Msg 17921, Level 18, State 1, Line 0
A recipient was specified ambiguously.

Error

In the above error message, I want to suppress the SQL Server error message and display only the error message ("Error") given in the print statement in my stored procedure. How do I do this?

Thanks in advance
P.C. Vaidyanathan

nr
SQLTeam MVY

12543 Posts

Posted - 2002-04-10 : 09:21:11
Fraid you can't. SQL Server always reports errors that it received.
If you want to protect a user from this then use a client to execute it.

==========================================
Cursors are useful if you don't know sql.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -