Take the 2-minute tour ×

I want to programmatically trace and save all queries and outputs (record rows) of queries execution in SQL Server 2008 R2.

I've easily implemented a query grace program based on TraceServer class of SMO (Server Management Object) in Visual C#.

However, I couldn't trace outputs (record rows) of queries execution which are like outputs in the results window in SSMS (SQL Server Management Studio).

How can I trace and save them?

share|improve this question
What about using SQL Server profiler for this? –  Brian Mains Nov 7 '12 at 1:58
add comment

1 Answer

You cannot obtain results of query execution with Profiler or SMO traces. Depending of what you are going to achieve, you can either run in SSMS queries captured with Profiler or you can create tables and add code into your queries to save results in the tables.

share|improve this answer
Thank you so much. Then, I have to implement a program that saves queries and their results for forensic evidence in ms sql database. Could you suggest any other method not losing much database performance? I think running queries captured takes so much times. –  user1804694 Nov 7 '12 at 8:29
@user1804694 You are welcome. But unfortunately I cannot suggest any other methods. It seems, there is no simple ways to solve your problem. –  Igor Nov 8 '12 at 4:19
add comment

Your Answer


