• ramadesai108 (11/9/2009)


    In this case what I will have to do is to insert the records into a temp table and thru a cursor check the previous Key value with the current one

    No, I'm pretty sure you don't have to do that.

    I never said there's no way, I said i don't understand your requirements. Explain more (and not with something like "top 4 records") and you'll very likely get a well-performing, easy solution. If I have to guess what you want, that's a lot less likely.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass