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
 General SQL Server Forums
 New to SQL Server Programming
 SELECT * TO XML OUTPUT

Author  Topic 

tmaiden
Yak Posting Veteran

86 Posts

Posted - 2009-11-13 : 09:22:39
I created an audit table and I would like to save old and new values. I am looking to dynamically set a field equal to the previous row value.

Lets say for the sample, I have a table called TABLE_NAME with 2 fields TBL_CD and TBL_NM

Example:
FIELDS
AUDIT_SK
CHANGED_TABLE
CHANGED_BY
CHANGED_ON
ORG_VALUE
NEW_VALUE
OPERATION
NOTES

SAMPLE DATA
1
TABLE_NAME
LNAME.FNAME
2009-11-12
<TBL_CD>21</TBL_CD><TBL_NM>SOME VALUE</TBL_NM>
<TBL_CD>21</TBL_CD><TBL_NM>NEW VALUE</TBL_NM>
UPDATE
WHY THE NAME WAS CHANGED


Any suggestions on how to generate ORG_VALUE? Granted I don't want to hard-code each node in, I want to dynamically pull the name of the field.

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-11-13 : 09:26:43
have a look at for xml feature in sql. that should give you a start
Go to Top of Page
   

- Advertisement -