Write to the event log

  • Whats the best/easiest way to write to the eventlog from a stored procedure?

    Right now I am using Raiseerror with log.

    Good or bad?

    /m

  • This is how I write to the eventlog when executing SQL in my DTS packages. As long as it doesn't interfere with the code you need to execute then I don't think there is a problem with doing this. I haven't found another way to do it from a query or SP.

    Robert W. Marda

    SQL Programmer

    bigdough.com

    The world’s leading capital markets contact database and software platform.

    Robert W. Marda
    Billing and OSS Specialist - SQL Programmer
    MCL Systems

  • I believe thats the only way, without doing some sp_Oa stuff

    Simon Sabin

    Co-author of SQL Server 2000 XML Distilled

    http://www.amazon.co.uk/exec/obidos/ASIN/1904347088


    Simon Sabin
    SQL Server MVP

    http://sqlblogcasts.com/blogs/simons

  • Take a look at

    xp_logevent

    in BOL

    Ex.

    xp_logevent 50001, 'Test Log', ERROR

    Would log an error to the event log with error number 50001 and test "Test Log".

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

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