error log in sql server2005

  • i have stored procedure as follows

    proc_multi_trans()

    {

    insert stmt

    // here i want to make a log in a file tht insert is success

    update stmt

    // here i want to make a log in a file tht update cmd is success

    delete stmt

    // here i want to make a log in a file tht delete cmd is success

    }

    i want to make those log entries..can anyone tell me whts the best way to achieve this?. plzz help

  • if you mean you want this in the SQL error log and windows event log use the raiseerror command

    Else the print or select command?

    ---------------------------------------------------------------------

  • thanks a lot for reply.... can i store this log in any file? i mean can i create my own error log file? logging my desirable information not only error information but also success information?

  • raiseerror goes to the SQL error log.

    How is this stored procedure going to be run?

    ---------------------------------------------------------------------

  • mail4sha (9/20/2010)


    thanks a lot for reply.... can i store this log in any file? i mean can i create my own error log file? logging my desirable information not only error information but also success information?

    These two links may help u in writing to a text file.

    http://www.nigelrivett.net/SQLTsql/WriteTextFile.html%5B/url%5D

    http://www.eggheadcafe.com/software/aspnet/32965051/appending-to-text-file.aspx%5B/url%5D



    Pradeep Singh

  • actually in every SP i have to make a log entry of every tranction done within the SP. i have to log both success n failure of transaction.... any possible way other than RaiseError?

  • mail4sha (9/20/2010)


    actually in every SP i have to make a log entry of every tranction done within the SP. i have to log both success n failure of transaction.... any possible way other than RaiseError?

    Why dont you run a trace for this?

    Other option may be writing triggers.



    Pradeep Singh

  • Hello Pradeep...

    Please can u tell me how trace works... this is wht exactly i m looking for... can u pls explain?

  • Google!!

    You can start here: http://technet.microsoft.com/en-us/library/ms175047.aspx%5B/url%5D

    Run a server side trace. Use profiler to script out the trace definition. Doing it manually can be error prone.

    This article of Gail will help you how to script out the trace definition and running it manually.

    [url]http://www.simple-talk.com/sql/performance/finding-the-causes-of-poor-performance-in-sql-server,-part-1/"> http://technet.microsoft.com/en-us/library/ms175047.aspx%5B/url%5D

    Run a server side trace. Use profiler to script out the trace definition. Doing it manually can be error prone.

    This article of Gail will help you how to script out the trace definition and running it manually.

    http://www.simple-talk.com/sql/performance/finding-the-causes-of-poor-performance-in-sql-server,-part-1/



    Pradeep Singh

  • thanks a lot... i will try as u said....

  • take a note that running traces (even server side) will cause a performance degradation.



    Pradeep Singh

  • oh.. thanks for ur valuable information

Viewing 13 posts - 1 through 12 (of 12 total)

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