Microsoft
Software
Hardware
Network
Question : Use UPDATE statement to update column data that increments by 1
I have a column in my table that needs to be updated to increment so that each row is 1 greater than the previous row. For example, the data currently looks like this:
Row Number
1 6000
2 6000
3 6000
but I need it to look like
Row Number
1 6000
2 6001
3 6002
and beyond. How can I do this?
Answer : Use UPDATE statement to update column data that increments by 1
it's not 100% clear if you want to get a "serial" generated on insert
-> use a IDENTITY field for the ID column
... or to update a existing non-identity column with sequential numbers
-> test the below UPDATE
1: 2: 3:
DECLARE @x INT SET @x = 0 UPDATE yourtable SET @x = ID = @x + 1
Open in New Window
Select All
Random Solutions
Internal Modem
Access Counter Field
Crystal Reports, ASP - How to create a web site to run reports out of MS Access 2000 tables
SBS 2003 Cold Backup and Restore using NTBackup.exe
WSS 3.0 & OWA 2007 -> Linking calendars???
Errors acessing OMA virtual directory
IIS Virtual Directory Management for SQLXML 3.0
Logging POP3-Traffic in Exchange 2000
wmv embedded in Flash 8 plays too fast
A few questions about the Route table