Differences between all columns of two rows based on date

  • Hey guys,

    I've got a table of stats which gets updated on a daily basis with an additional row for that day, at the moment, including the date field this table has 55 fields. What I'm trying to do is ascertain if any of the values have changed by X%, so like a quality control threashold, set it to say 1%, any changes over that would require a quick look.

    I've established how to do for one column, which I could repeat for multiple columns, however, I'm wondering if there's anything fancy to do the whole lot in one go and allow for future columns too?

    This is the logic I've been following thus far: http://blog.namwarrizvi.com/?p=29

    I can blindly copy/paste using dispstru I guess, however, I sense there's a more compact and elegant solution I'm not spotting! - Any help much appreciated.

  • I don' think there is an easy way to do this because you still have to do A.col1 - B.col1 for each column to get a difference. You could probably do something with Dynamic SQL using the sys.columns table to generate the SQL you need to run, but I'm not sure it will really be a time saver for you unless you add columns often or need to do this for multiple tables.

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply