Update a table column with a sequence number v3

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=1643v2:http://www.sqlservercentral.com/scripts/viewscript.asp?scriptid=1664Since neither script requires a specific order for the sequence number, the same result can be achieved with a single UPDATE statement.

2006-04-26 (first published: )

329 reads

Blogs

T-SQL Tuesday #137–Notebook Uses

By

It’s actually my month to host T-SQL Tuesday, and I came up with the...

Daily Coping 13 Apr 2021

By

I started to add a daily coping tip to the SQLServerCentral newsletter and to...

Converting a SQL Server Docker image to a WSL2 Distribution

By

Windows Subsystem for Linux is probably my favourite feature of Windows 10. It gives...

Read the latest Blogs

Forums

Sorting in R

By Steve Jones - SSC Editor

Comments posted to this topic are about the item Sorting in R

Oracle sequences: The basics

By Additional Articles

Comments posted to this topic are about the item Oracle sequences: The basics

Bug Management

By Steve Jones - SSC Editor

Comments posted to this topic are about the item Bug Management

Visit the forum

Ask SSC

SQL Server Q&A from the SQLServerCentral community

Get answers

Question of the Day

Sorting in R

See possible answers