Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Stored Procedure - Saving/Logging Messages

Author  Topic 

mmuruli
Starting Member

1 Post

Posted - 2011-02-09 : 02:49:03
I am working on a Stored Procedure which calls another Stored Procedure Dynamically, depending on the Server and Database where the 2nd Stored Procedure resides. It is required to PRINT the Execution scripts from the 2nd stored procedure which are normally returned to the Messages window in SQL Server while the Procedure executes, to a database. In other words, to create a sort of logging mechanism.

Ideally if there is a way that I can save all the Execution steps in one large string field called 'ExecutedQueries' into the database, which will save all Queries & Error messages ran by the second stored procedure; then I will be in business. This will help identify future issues, or even help rollback a change.

Currently, I am manually inserting field values into the logging table such as StartTime, EndTime, Duration, etc. Can someone show me an example of how I can capture the Output messages from the Executing Stored Procedure to a long character field in the database?
   

- Advertisement -