• Many times we need to rely on records being next to each other to determine next Value ordered by a Date, let's say. So, if the identity column is called "Ref". We need to rely on Ref = Ref-1. It doesn't necessarily have to display in that order, but the Refs have to be in order based on the fields we determine. Here's a quick example of something we would do. The Clustered Index would be on Vendor, Item, and ChangeDate for this example.

    Update tmpCost

    set cur.NextCost = nxt.ListCost

    from tmpCost cur

    inner join tmpCost nxt

    on cur.Vendor = nxt.Vendor

    and cur.Item = nxt.Item

    and cur.Ref + 1 = nxt.Ref

    Thanks.

    Kris Robinett