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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Comparing Values Within Same Record 1

Status
Not open for further replies.

PGO01

Programmer
Jan 8, 2008
156
GB
I've got some audit tables populated by triggers - each audit table has an Inserted_xxx and Deleted_xxx column for each column in the original table.

Is there a good way to select the Inserted_XXX and Deleted_XXX columns only where they are different?

So if I have a table with 20 columns I will have an audit table with 40 columns, 20 prefixed with Inserted_ and 20 prefixed with Deleted_. If only 1 of the columns is changed in the source table, all old values and new values are propagated to the audit table, and I then want to have a view/function/proc to show me just the old and new values where there is a difference. (Along with the column name).

Ultimately I want the end result put into a varchar(max) variable.

Any help/suggestions are appreciated.
 
Never heard of that before, thank you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top