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
 General SQL Server Forums
 New to SQL Server Administration
 Log SQL-Queries on SQL-Server 2005 and higher

Author  Topic 

fabsen2102
Starting Member

1 Post

Posted - 2009-07-15 : 02:56:02
Hi together!

Do anyone of you know a chance to log all SQL-Queries which the SQL-Server has execute. I thought there could be a way to choose between "only SELECTs", "only UPDATEs", "everything" or so.

I hope everybody know what I mean. If not, let me know...

Thanks a lot!

Fabian

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2009-07-15 : 05:34:20
have a look at sp_trace_create http://msdn.microsoft.com/en-us/library/ms190362.aspx
Go to Top of Page

lionofdezert
Aged Yak Warrior

885 Posts

Posted - 2009-07-22 : 06:23:07
SELECT deqs.last_execution_time AS [Time], dest.TEXT AS [Query]
FROM sys.dm_exec_query_stats AS deqs
CROSS APPLY sys.dm_exec_sql_text(deqs.sql_handle) AS dest
--WHERE dest.TEXT LIKE '%YOUR DESIRED TABLE%' --here you can provide your desired table name
ORDER BY deqs.last_execution_time DESC
Go to Top of Page
   

- Advertisement -