We help IT Professionals succeed at work.

SQL Profiler

I am trying to look at a performance issue within SQL and need to be able to monitor what tables are being opened within SQL at a given time , I have been using SQL Profiler but cant seem to work out how I can get a list of tables being opened at a certain time , I need to basically run a test on my database and at a certain point start the profiler and then list just what tables are being opened then stop SQL Profiler , Anyone any ideas on how I can do this , I will want to capture the list over about a 15 min time period
Watch Question

IT Engineer
Distinguished Expert 2017
You can use this code to check which table was accessed during the last 15 minutes (you can change the time period of course):
USE DatabaseName

SELECT OBJECT_NAME(object_id) ObjName, last_user_seek, last_user_scan, last_user_update
FROM sys.dm_db_index_usage_stats
WHERE database_id=DB_ID()
	AND (last_user_seek >= DATEADD(minute, -15, GETDATE())
			OR last_user_scan >= DATEADD(minute, -15, GETDATE())
			OR last_user_update >= DATEADD(minute, -15, GETDATE()))

Open in new window


Thankyou Vitor ,

I was thinking it needed to be more complicated than that but it gives us what we needed

Vitor MontalvãoIT Engineer
Distinguished Expert 2017

Keep it simple ;)