How to add custom event id into eventlog from SQL Server

  • Hi all,

    The situation is like that, I am running some deleting jobs and want to track

    errors while deleting if any error occurs i need it to go into Eventlog of the system.

    Is is ok to log event but the problem is that I need my own event id need to be

    inserted into the eventlog.

    Please provide help to achieve this.

    Let me know if you need additional info.

    Thanks in advance.

  • You can create you're own custom error using sp_addmessage. If you use the WITH LOG option the error is written to the SQL errorlog and the application log.

    USE master

    GO

    EXEC sp_addmessage @msgnum=50001,

    @severity =16,

    @msgtext = N'Error during delete.',

    @with_log = 'TRUE';

    GO

    [font="Verdana"]Markus Bohse[/font]

  • Thanks Marks,

    I am facing the problem as this 5001 is written into message not in the eventid,

    is this 5001 will be written as event id in your case?

    Today I am leaving now, i will try it tomorrow.

  • while deleting if any error occurs i need it to go into Eventlog of the system

    Try RAISERROR WITH LOG

  • Thanks all for your answers,

    I am able to log these message into eventlog, but my requirement is that I need my custom eventid and may be custom datasource,

    Is this possible?

    I know there will be a way around..

    Need to investigate, learn ..

    Thanks

Viewing 5 posts - 1 through 4 (of 4 total)

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