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 2000 Forums
 SQL Server Development (2000)
 Query DB to list all newly added records ?

Author  Topic 

Milo Cold
Starting Member

14 Posts

Posted - 2004-11-03 : 14:12:46
Greetings All,

Ok, I'm trying to figure out if it is possible to run a query against a database containg over 20 tables, in search for any and all records in all tables that may have been added/altered. Essentially, all I want is a list of all updated records in an entire DB, is this possible?

I leaning towards just creating a procedure that checks each table w/in the DB for recent changes, and then displays the results. However, I can't think of the code to limit the results to recent additions or edits.

Any advice would be much apprieciated! Thanks in advance

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2004-11-03 : 14:36:26
well how do you define recent changes??
to do that you need some datetime column in each table, that gets updated whenever data in row gets changed...
then you simply do
select * from table where dateColumn >= desired date

Go with the flow & have fun! Else fight the flow
Go to Top of Page

Milo Cold
Starting Member

14 Posts

Posted - 2004-11-03 : 15:11:40
quote:
Originally posted by spirit1

to do that you need some datetime column in each table



Yeah, that would work but every table would require a that column (as you said) and they don't. I know I can remedy that problem, but I was just curious if another method existed. Thanks for the 411 though!
_miloCold
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2004-11-03 : 15:29:08
without having that column that is probably impossilble...
maybe if u check the transaction logs somehow...

Go with the flow & have fun! Else fight the flow
Go to Top of Page

jen
Master Smack Fu Yak Hacker

4110 Posts

Posted - 2004-11-03 : 22:08:10
or if you create an update,insert trigger on those tables and save the information in another table for audit later on...

--------------------
keeping it simple...
Go to Top of Page
   

- Advertisement -