Unanswered: Capturing warnings?
Hi all, I know that it's fairly trivial to capture SQL error conditions (i.e. constraint violations, etc) by using code similar to:
But what about warnings? I would like to trap for warnings such as
SELECT @m_error = @@Error IF @m_error <> 0 GOTO ErrorHandler
SET @TraceMsg = 'Rebuilt new index for ' + CONVERT(varchar(10), @CreateDate, 101) + ' (' + @RowCount + ' component stocks added)'
EXECUTE [dbo].[tracelog] 1, 'Index', 'sp_Rebuild_CurrentList', @TraceMsg
DECLARE @func VARCHAR(50)
SELECT @func = Object_name(@@Procid)
EXECUTE [dbo].[ErrorHandler] @m_error, 'Index sp', @func
and write when this happens to a trace file.
Warning: Null value is eliminated by an aggregate or other SET operation.
Of course, another alternative would be to catch the problems as they are added to the database, but I don't have control over the input database, so would have to check it prior to using it, and that's a bit more effort than necessary for this particular project - since, however, I have run across the desire to capture warnings in the past, I must pose the question
Any ideas? Anyone have a need to capture warnings of this type before?
Non est ei similis.
I just read "100 Things To Do Before You Die". I was surprised that "Yell for help!!" wasn't one of them