0

Im not even sure how to write this out. Would I put the logic in a case when?

select personnum, orgid, eventdate
from dbo.totals
where eventdate = '10-08-2013'

There can be multiple orgids applied to a personnum throughout a day. When there is a change in orgid, I want to return that change.

user2800758
  • 5
  • 1
  • 3
  • Please see my auditing table with triggers response. http://stackoverflow.com/questions/11890868/how-to-store-historical-records-in-a-history-table-in-sql-server/19144370#19144370 This solution will keep track of an audit trail in xml data format. – CRAFTY DBA Oct 10 '13 at 18:40
  • It would be helpful if you added the schema of the table and some sample data. – Jon Boulineau Oct 22 '13 at 01:08

1 Answers1

0

It sounds like you want to use a trigger to write to a separate table which contains details of the changes.

You would create an update trigger on the table in question, and use the values in inserted and/or deleted to detail the changes.

podiluska
  • 50,950
  • 7
  • 98
  • 104
  • I do not want to update the field though. I simply want to extract the data when a user changes his orgid column. I feel like I don't need to create a table for this. I just want to display what changed. – user2800758 Oct 10 '13 at 20:39