Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to find the exact SQL a user has run recently

Status
Not open for further replies.

mm8294

MIS
Oct 12, 2001
73
US
Hi, guys. We have a problem with a developer here, and I need find out the exact SQL he ran recently. I have no idea which sql he ran, it could be SELECT, DELETE, or UPDATE. The only info I have is his user name. I started to do my research last week, but no luck. I am not very familiar with SQL Server. A buddy told me as far as he remember, there is a stored procedure to do this, but he is not sure.

Is there any table in SQL Server to do this?

Any help is very appreciated.

Thanks in advance.
 
There is no table in SQL Server that contains the SQL code that was executed for a user.

The options you have, and there may be a few others that our forum may add but, you would have to have SQL Profiler running in the background to capture that information.

Of course it needs to be running already to capture the code so in this case where Profiler was probably not running last week ... we do not have a trace to look at.

The other option would be to see if you knew when (maybe a date range) the code was executed and if it were an INSERT/UPDATE/DELETE operation, you may be able to use a 3rd party log exploring tool to find the code in the tlogs.

Last possible option, and I rarely see this one, is to have an application method that is trapping and archiving the DML calls. This is highly unlikely and the only one I ever came across only logged D/I/U operations and not SELECT operations.

Hope this helps!

Thanks

J. Kusch
 
JayKusch,

Thank you so much for your help. I will use the profiler to do it. Hope it works.


I appreciate your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top