How to check data is inserted deleted or updated in ms sql database

  By Junaid A   Posted on November-07-2022 

Problem:

Sometime, we are not sure, which database table are being used.so we want check which tables are in use


Solution:

SELECT 
      [db_name] = d.name
    , [table_name] = SCHEMA_NAME(o.[schema_id]) + '.' + o.name
    , s.last_user_update
FROM sys.dm_db_index_usage_stats s
JOIN sys.databases d ON s.database_id = d.database_id
JOIN sys.objects o ON s.[object_id] = o.[object_id]
WHERE o.[type] = 'U'
    AND s.last_user_update IS NOT NULL
    AND s.last_user_update BETWEEN DATEADD(wk, -1, GETDATE()) AND GETDATE()

By  asifjans    07-Nov-2022 Views  44



Comments


Your Comments

You may also read following recent articles