Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Increment field

Author  Topic 

mshsilver
Posting Yak Master

112 Posts

Posted - 2010-09-30 : 04:44:47
Hi,
I have a table with thousands of rows of data and i really need to add a new field called "autonumber" and in that field i need to update each row with an incrementing number starting from one. It does not matter what record starts with the numbering but i need them to all get an auto number.

I've tried things i've found online but not getting anywhere, any advice please?

Sachin.Nand

2937 Posts

Posted - 2010-09-30 : 04:53:36
[code]
alter table yourtable
add autonumber int identity(1,1)
go
[/code]

PBUH

Go to Top of Page

mshsilver
Posting Yak Master

112 Posts

Posted - 2010-09-30 : 06:18:25
That is just what i needed thank you very much.
Go to Top of Page
   

- Advertisement -