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

  By Junaid A   Posted on November-07-2022 


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


      [db_name] =
    , [table_name] = SCHEMA_NAME(o.[schema_id]) + '.' +
    , 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


Your Comments

You may also read following recent articles