SQL Stored Procedure to resequence pointer field
Posted on 2011-05-09
I am writing an application in VB.Net 2008 which uses SQL Server 2005. The particular database I Am working with now holds Stock records which has a Primary Key and a Sequence number. The user may add multiple records and may also remove records from the database which will create gaps in the Sequence.
Since there will or could be gaps I wanted to call a Stored Procedure to re_swquence the records. I thought I could use a WHILE loop with a variable, but the UPDATE only updates the last record. Could you show me a Stored Procedure that coulld accomplish this.