Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find recent object changes in SQL Server Database

I've added and modified several (new and existing resp.) tables and stored procs, for a particular database and server, in last 3 months.

I was thinking if there's any SQL query by which I can determine all those changes.

Thanks.

like image 340
Kings Avatar asked May 16 '14 17:05

Kings


People also ask

How do I find the latest modified object in SQL Server?

Query the sys. objects table to find the objects that changed and filter by modify_date and type ; U = User table, P = Stored procedure. This approach will tell you what objects have changed, but not the specific changes.

How do I find recent changes in SQL?

To get the last updated record in SQL Server: We can write trigger (which automatically fires) i.e. whenever there is a change (update) that occurs on a row, the “lastupdatedby” column value should get updated by the current timestamp.

How do you find out who modified an object in SQL Server?

The name of the report is Schema Changes History. To run the Schema Changes History report open SQL Server Management Studio, make a right click on an object (the instance name or a database name, for example), then select "Reports", click on "Standard Reports", and then click on "Schema Changes History" report.

How do I track changes in database?

To track changes, change tracking must first be enabled for the database and then enabled for the tables that you want to track within that database. The table definition does not have to be changed in any way, and no triggers are created.


2 Answers

Query the sys.objects table to find the objects that changed and filter by modify_date and type; U = User table, P = Stored procedure.

select * 
from sys.objects 
where (type = 'U' or type = 'P') 
  and modify_date > dateadd(m, -3, getdate()) 

This approach will tell you what objects have changed, but not the specific changes.

like image 186
tjhazel Avatar answered Oct 19 '22 00:10

tjhazel


Hi you can get the changed/modified db object details with this query

select name,create_date,modify_date
from sys.procedures
order by modify_date desc

Thanks

like image 40
Tapan kumar Avatar answered Oct 18 '22 23:10

Tapan kumar