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)
 Logging error description in stored procedure

Author  Topic 

TsqlWorld
Starting Member

14 Posts

Posted - 2008-07-18 : 14:40:57
Need your help to catch error description & insert into log table

I have added following type of code.

DECLARE @ret int, retmess varchar(50)
exec @ret=@Proc_name

IF @ret <> 0
BEGIN
print 'Error # is ' + ltrim(str(@ret)) + '.'
select @retmsg = [description] from master.dbo.sysmessages where error = @ret and msglangid=1033; -- for english
print 'Error Message - ' + @retmsg + '.'
END

Out put is something like this

The statement has been terminated.
Error # is 547.
Error Message - The %ls statement conflicted with the %ls constraint "%.*ls". The conflict occurred in database "%.*ls", table "%.*ls"%ls%.*ls%ls..

This doesn't give me correct error message.

Thanks

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2008-07-18 : 14:43:45
Duplicate, locking thread.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page
   

- Advertisement -