Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get history of table structure change in SQL Server

I have a table in SQL Server 2012. The table has few columns. Now I need to check for which column and what is the DDL script has been executed on this table. Or if it is possible to get what is the latest ALTER has been executed for this table.

Thanks in advance.

like image 894
Arindam Avatar asked Mar 23 '17 10:03

Arindam


People also ask

How do you find the history of a table?

To find the name of the history table you can use the system table sys. tables along with the system function OBJECT_NAME. From sys. tables, you have to use the column history_table_id to get the object_id of the history table for the given current table.


1 Answers

You cannot achieve this if you do not have a historical or archive table that store this data (using a DDL Trigger) or using a source control.

OR

You have to use a third-party log reader (if log is not shrinked) like ApexSQL LOG

like image 125
Hadi Avatar answered Oct 10 '22 03:10

Hadi