Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 How can pull all tables that have changed recently

Author  Topic 

mgreen84
Yak Posting Veteran

94 Posts

Posted - 2014-05-08 : 13:34:38
Does anyone know a script that can be used to determine tables that have changed or been updated in a certain time frame?

ScottPletcher
Aged Yak Warrior

550 Posts

Posted - 2014-05-08 : 14:25:39
Do you mean the schema/definition of the table changed or rows inserted/updated?

For rows inserted/updated, you would need to add a column to the table to identify that. SQL doesn't automatically try to track that, as it would be far too much overhead when not needed.
Go to Top of Page

mgreen84
Yak Posting Veteran

94 Posts

Posted - 2014-05-08 : 14:32:38
Yeah I was referring to a schema change or column added to table

quote:
Originally posted by ScottPletcher

Do you mean the schema/definition of the table changed or rows inserted/updated?

For rows inserted/updated, you would need to add a column to the table to identify that. SQL doesn't automatically try to track that, as it would be far too much overhead when not needed.

Go to Top of Page

ScottPletcher
Aged Yak Warrior

550 Posts

Posted - 2014-05-08 : 17:32:05
You can try using the modify_date in sys.objects, but it's probably better to just capture the schema yourself and test for changes later.
Go to Top of Page

jackv
Master Smack Fu Yak Hacker

2179 Posts

Posted - 2014-05-09 : 01:45:20
Yes. The SQL Server default trace has the Object Altered event. which registers when DDL changes occur. Use the script on http://www.sqlserver-dba.com/2012/04/who-made-ddl-table-changes-on-the-database.html
Assuming the default trace files haven't rolled over

Jack Vamvas
--------------------
http://www.sqlserver-dba.com
Go to Top of Page
   

- Advertisement -