October 18, 2012 at 5:10 pm
Hi all,
I'm working on a new project that needs to keep track of the activities of the users. Is there a way to save the query that has been executed?
It will be a reporting application, so I could save the parameters used, but I supposed that I could save the entire query as well.
October 18, 2012 at 5:15 pm
Right after posting, I found this (made for 2005 but worked on 2008)
http://blog.sqlauthority.com/2008/01/03/sql-server-2005-last-ran-query-recently-ran-query/
However, other options are welcome.
October 18, 2012 at 5:24 pm
Profiler (SQL Trace) or extended events. The method given by that blog is not complete. It only catches queries whose plans get cached.
If your logging just has to be close enough, that's probably fine. If it needs to be completely accurate, it's not.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
October 19, 2012 at 3:38 am
The way to get the queries executed on the system with the least amount of impact on that system is to use Extended Events. Just be prepared. You're going to be dealing with lots and lots of data if you capture every query against the server.
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
October 19, 2012 at 8:45 am
Thank you for your responses, I will check on these and choose a way to do it.
Now I have several options and need to see which fits better to this.
Viewing 5 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply