Display the modification date of a SQL Server table

How to display the modification date of a SQL Server table? This sample SQL query uses SQL Server system tables to detect the latest changes made to a SQL Server table or view. It displays the creation date and the last update date.

Moreover, this query only takes into account the tables because it reads the data from the system table sys.tables.

How to display the modification date of a SQL Server table?

Indeed, this SQL script displays the list of tables created in the database. That is to say the “non-system” tables, as well as the creation date and the last update date. In addition, the query selects the data from the MS RDBMS system table.

Note that the dates correspond to changes in the structure of the table and not to the contents.

SELECT
[name],
[type],
[type_desc],
[create_date],
[modify_date]
FROM sys.tables
WHERE name like '%'
ORDER BY modify_date DESC,
create_date DESC;

Finally, to display the same information for a view, use the same code and replace sys.tables with sys.views.

System tables also allow you to display the full month name with SQL Server with a T-SQL query.

What are SQL Server system tables?

SQL Server system tables are tables used by the database management system and the SQL engine. In effect, these tables store the list of SQL Server objects and allow the database to function. It is strongly recommended that you do not edit these tables directly.

Be the first to comment

Leave a Reply

Your email address will not be published.


*