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.
| Author |
Topic |
|
hankswart@hotmail.com
Starting Member
2 Posts |
Posted - 2005-09-12 : 11:55:56
|
| Hi Guys,I have been tgrying to figure out a way to add "SQL Generated Error's" to a error logging table. What I mean by this is that when ever sql generates an error it must send the error message to the error table.E.g.BEGIN DECLARE @iErrorNo INT DECLARE @sErrorMessage VARCHAR(4000) INSERT INTO Table1 (field1, field2, field3, field4) VALUES (1, 'Value 2', 3, 'Value 4') SET @iErrorNo = @@ERROR SET @sErrorMessage = ( SELECT Description FROM master..sysmessages WHERE (error = @iErrorNo) ) IF @@ErrorNo <> 0 BEGIN INSERT INTO tblError (ErrMsg) VALUES (@sErrorMessage) ENDENDThe above works but the object names aren't populated as you would usually do with RAISERROR.Has anybody ever done anything similar?Any help would be appreciated... |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
|
|
|