Wednesday 26 December 2018

Get the list all Database object which are created or modified from last 15 days

We are creating a dashboard where we are monitoring the database object modification (alter). With the help of below script, we will get the list of all altered object.
Object alter
SELECT o.type_desc,o.type,o.name,o.create_date,
o.modify_date,DATEDIFF(D,o.modify_date, GETDATE()) as Dayes
FROM sys.objects o
inner join sys.all_objects m
on o.object_id=m.object_id
WHERE o.type in ('C','D','F','FN','P','PK','SN','TF','TR','TT','U','UQ','V')
and DATEDIFF(D,o.modify_date, GETDATE()) < 15

  

Object created
SELECT o.type_desc,o.type,o.name,o.create_date,o.modify_date,
DATEDIFF(D,o.create_date, GETDATE()) as Dayes
FROM sys.objects o
inner join sys.all_objects m
on o.object_id=m.object_id
WHERE o.type in ('C','D','F','FN','P','PK','SN','TF','TR','TT','U','UQ','V')
and DATEDIFF(D,o.create_date, GETDATE()) < 15


   
We will get the type description on below link.


No comments:

Post a Comment

If you have any doubt, please let me know.

Popular Posts