Logging every database error in a table

  • We have developed our asp.net application using SQL Server 2005. Now I want to log each and every database error into a log error table. I can't modify each and every stored procedure. Is there any other way like writing a stored procedure that will store any database error?

    Thanks in advance...

  • [font="Verdana"]The best way is to capture all the errors for that database is to run a profiler trace in background and store it in a table. You need to use Errors & Warnings events and filter it using dbid or dbname. [/font]

  • Thanks a lot Vidya. It has solved the problem. Now I am able to save every database error.

    However sometimes I am using RaiseError to raise some custom exception for the user understanding and I don't want to save them into table. Is there any way or filter for them?

    thanks...

  • Here I am facing one more problem. If I'll close the SQL Profiler window then the trace stops working. so out to make it run in the background so that it will run after closing Profiler window also...

    This will help me a lot and any suggestion will be appriciated.......

  • Hello,

    One question - do you want to log DB errors to a table over a long period?

    The Profiler is normally used for short term analysis e.g. in bug hunting or identifying performance issues. Long term use can have a performance hit on your server.

    If you want to capture this information every day then you could instead use a tool such as LogParser to regularly extract data from the SQL Server Log and load it into a DB table. (LogParser is available from MS Downloads).

    Regards,

    John Marsh

    www.sql.lu
    SQL Server Luxembourg User Group

  • Will this tool log each and every error at the time of error generation or anything else?

    My requiremnt is to log each error related to a perticular database into a table.

  • Hello,

    LogParser extracts information from the SQL Server Log, but not in real time. You would need to schedule it to run every day/hour/minute etc depending on your requirements.

    It can filter the information that it extracts, so you may be able to limit it to just the errors that you require.

    Regards,

    John Marsh

    www.sql.lu
    SQL Server Luxembourg User Group

  • Hi,

    If the application is being used during a specific time window and you want to collect the error for the specific time window, you can setup a scheduled trace to run for the specific time duration and get them into a trace table automatically.

    Check the following link for scheduling a trace and collecting them into a table.

    http://www.novicksoftware.com/Articles/scripting-traces-for-performance-monitoring-on-sql-server.htm

    Hope this helps.

    Cheers,

    Imran.

Viewing 8 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic. Login to reply