• Matthew Cushing (8/30/2012)


    Going to give it a try now, but I'm unsure what this does:

    ROW_NUMBER() OVER( ORDER BY position_id) + @new_position_id - 1

    That's taking the new position_id and adding the Row Number minus 1 to avoid a gap between sets.

    I'm guessing your SP GetUpLdNextInstance is doing something like this:

    SELECT ISNULL( MAX( idcolumn), 0) + @Increment

    FROM IDsTable

    WHERE Table = @Table

    AND Column = @Column

    Am I correct?

    Are you sure the new_position_id is getting the same value on every row? Can you check what is it trying to insert?

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2