Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Returning Records by Date Range

Status
Not open for further replies.

PieMan

Programmer
Aug 9, 2001
15
0
0
GB
Is there an easy way of automatically assigning a DateTime to a row every time a row is added or amended?

I could hard code it using VB, but I'm hoping that SQL Server can do it for me.

The reason being is that I would like to query several (200+) tables and return only the records that have been added or modified during a given time span i.e. a working week.

Thanks

Pieman
 
You would have to add an extra datetime column to each table you wish to audit and then create SQL Server insert and update triggers to do what you require.

This method is very popular amongst other SQL Server sites. Be aware there is a slight overhead on performance when using triggers.

Have a look in BOL under the topic triggers to get you started.

Rick.
 
You would have to add an extra datetime column to each table you wish to audit. Then create SQL Server insert and update triggers to add todays date to the rows which are inserted and updated.

This method is very popular amongst other SQL Server sites. Be aware there is a slight overhead on performance when using triggers.

Have a look in BOL under the topic triggers to get you started.

Rick.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top