Best Practices - Stored Procedure Logging

后端 未结 4 1801
后悔当初
后悔当初 2021-02-07 02:25

If you have a long running SP, do you log somehow its actions or just wait for this message?

\"Command(s) completed successfully.\"

4条回答
  •  忘了有多久
    2021-02-07 03:14

    How are you invoking the stored procedure? If it is through Management Studio then you can easily print out the message as follows

    RAISERROR ('Some debugging info', 0, 1) WITH NOWAIT
    

    This is preferable to using PRINT as the message will appear immediately. These messages can also be caught in ADO.NET by wiring up a handler for the Connection.InfoMessage event.

    I see that you have already listed SQL Profiler as a possibility. You might be interested to know that you can log your own user configurable events that can be seen in SQL Profiler.

提交回复
热议问题