Getting list of modified objects in SQL Server

SQL Server

Sometimes it always helps to get the list of all modified tables or stored procedures before check-in the code or wrapping up the development for the build. Some developers usually keep this kind list in a file and they update this file every time they modify any table or stored procedure in their development environment. Following are some handy SQL snippets which can provide you list of the tables, or stored procedure modified in the specified duration.

12345
-- tables modified today
SELECT [name],create_date,modify_date
FROM sys.objects
WHERE modify_date>DATEADD(day,-1,GETDATE())
AND type='U'

12345
-- stored procedures modified today
SELECT [name],create_date,modify_date
FROM sys.objects
WHERE modify_date>DATEADD(day,-1,GETDATE())
AND type='P'

You can further tweak above query to specify a more specific duration, for example, objects modified in last 7 days.

12345
-- tables modified in last 7 days
SELECT [name],create_date,modify_date
FROM sys.objects
WHERE modify_date>DATEADD(day,-7,GETDATE())
AND type='U'

Tags: sql, sqlserver, tsql