I need a code for the following scenerio
In a dataset I have columns like Acc_sk,Acc_ID, Coll_Status,Valid_from and Valid_to
Dataset:Account
Acc_sk Acc_ID Coll_Status Valid_from Valid_to
1 001 open 4-13-2009 12:00:09 PM 4-13-2009 23:00:09 PM
2 001 closed 4-13-2009 12:00:10 PM 1-1-2010 23:00:09 PM
3 001 open 1-1-2010 23:00:09PM 1-1-5999 00:00:00
4 002 open 4-13-2009 12:00:09 PM 4-13-2009 23:00:09 PM
5 002 closed 4-13-2009 12:00:10 PM 1-1-5999 00:00:00
I need to apply check in this table that wether the difference between valid_from of each Acc_ID where max(valid_to) and valid_to of its previus row should be of one sec.
Moreover I need to make it generic where the value of target table will be in a macro and also the value of columns(like Acc_ID) will also be stored in a macro as a comma separated list.(means it could be one column or combination of one or more columns)