Listing Updated Tables in SQL Server

Hello everyone,

In this article, I will talk about how to list updated tables in SQL Server.

In SQL Server, in some cases, it may be desirable to know which tables have been updated.

I will describe my transactions using the Northwind database.

Let’s check if there is a change on the related database using the following query.

SELECT tbl.name,
       ius.last_user_update,
       ius.user_updates,
       ius.last_user_seek,
       ius.last_user_scan,
       ius.last_user_lookup,
       ius.user_seeks,
       ius.user_scans,
       ius.user_lookups
FROM sys.dm_db_index_usage_stats ius
    INNER JOIN sys.tables tbl
        ON (tbl.object_id = ius.object_id)
WHERE ius.database_id = DB_ID();

When we call the query before making changes to any table, you will get a result like the one below.

Listing Updated Tables in SQL Server

As you can see, it came up empty because we didn’t make any changes (Insert, Update, Delete) in the database before.

Now, let’s make the CategoryName name Deniz Ürünleri for the category with CategoryID=8 in the Categories table.

UPDATE dbo.Categories
SET CategoryName = 'Deniz Ürünleri'
WHERE CategoryID = 8;

Let’s run the query.

Listing Updated Tables in SQL Server

As you can see we have updated it. Now let’s check with the first query we wrote.

Listing Updated Tables in SQL Server

As you can see, it showed us that there was an update in the Categories table.

Good luck to everyone in business and life.

182 Views

Yavuz Selim Kart

I try to explain what I know in software and database. I am still improving myself by doing research on many programming languages. Apart from these, I am also interested in Graphic Design and Wordpress. I also have knowledge about SEO and Social media management. In short, I am a determined person who likes to work hard.

You may also like...

Don`t copy text!