Tuesday, June 03, 2008

Creating a Sequential Record Number field - SQLTeam.com

When does Something = Something = Something?  Only in SQL....

This little piece of code will run through a table and sequentially number the field you specify. The only drawback is that it will determine the order based on the physical order of the table.
declare @intCounter int
set @intCounter = 0
update Yaks
SET @intCounter = YakSequenceNumber = @intCounter + 1

Creating a Sequential Record Number field - SQLTeam.com

No comments: