Switch two record's sequences

  • Hello everyone.

    I was wondering if there was a more efficient way to switch two record's sequences that reside in the same table. I want to be able to move a record higher or lower in a sequence. Right now I have two update statements for each of these operations. One update to set the sequence of the higher record down one, and another update to set the sequence of the lower record up one. Is there a more efficient way of doing this?

    Best,

    Bob

  • We need a bit more info to help you. 🙂

    Read this article and re-post.

    http://www.sqlservercentral.com/articles/Best+Practices/61537/

    ______________________________________________________________________

    Personal Motto: Why push the envelope when you can just open it?

    If you follow the direction given HERE[/url] you'll likely increase the number and quality of responses you get to your question.

    Jason L. Selburg
  • By "sequence", do you mean a column with the Identity property? If so, it's a mistake to be concerned with either the order of rows or gaps in identity column values. The identity property should only be used to automatically generate a unique value when a row is inserted.

    Greg

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

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