Both Sachinvaishnav and Mark Chad have submitted scripts to populate a column with a sequence number. The first solution uses a cursor; the second uses the SQL 2005 ROW_NUMBER() function.
v1:
http://www.sqlservercentral.com/scripts/viewscript.asp?scriptid=1643
v2:
http://www.sqlservercentral.com/scripts/viewscript.asp?scriptid=1664
Since neither script requires a specific order for the sequence number, the same result can be achieved with a single UPDATE statement.
2007-10-02 (first published: 2002-06-20)
15,451 reads