I have a SQLServer table that contains snapshot data. I need to compare the latest row against the previous and determine if certain columns have changed. I need to do this several times comparing different combinations of columns, up to 40 at a time. Every time a column value differs within one of the combinations I need to create an xml document containing the latest values. I expect every row to produce at least one xml document.
Where is the best place to perform the comparison, should I do this in stored proceedures, one for every combination of columns. Or should I pull back the whole rows via ADO.NET and compare them in code? Is there an easy way of doing the comparison?