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
 SSIS and Import/Export (2008)
 Data changed and column name capture

Author  Topic 

under2811
Constraint Violating Yak Guru

366 Posts

Posted - 2011-11-08 : 02:34:18
Hi All,

Is it possible to capture the column name and the data changed in that column in seperate column means old data and new changed data?

T.I.A

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-11-08 : 03:04:15
its possible. you can add an audit trigger to capture this information
you can also use change data capture

http://weblogs.sqlteam.com/derekc/archive/2008/01/28/60469.aspx

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-11-08 : 04:32:17
yep. you can use OUTPUT clause if you need to capture the changed values from magic tables INSERTED,DELETED inline in script where you do insertion to master tables

see

http://blogs.msdn.com/b/sqltips/archive/2005/06/13/output-clause.aspx

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-11-08 : 07:00:50
quote:
Originally posted by under2811

Hi,

I need this type of output in table.

A B C Start Date End Date Change
a 34 43 01/01/2009 06/08/2009 Null
a 34 44 06/09/2009 07/13/2009 C => 43 to 44
a 41 46 07/14/2009 Null B =>34 to 41, C => 44 to 46

T.I.A


this is typical case where you capture changes with audit trigger

see an example script here

http://www.nigelrivett.net/AuditTrailTrigger.html

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -