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 2000 Forums
 Transact-SQL (2000)
 add auto id or auto number to existing table

Author  Topic 

Job
Yak Posting Veteran

69 Posts

Posted - 2005-08-20 : 22:51:54
I have an existing table w approx 6mm lines. I now need an Auto id field. Is there a way to do this?

Cheers

Job
Yak Posting Veteran

69 Posts

Posted - 2005-08-21 : 00:03:06
Ok,

I used this and it seems to work...



Alter Table Tbl_Txn_Line_CHS

add AutoNum Numeric(5,0) identity
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2005-08-21 : 02:16:16
That will do the trick. You might have been better off using an INT datatype

The NUMERIC will use 5 bytes, the INT only 4 and applications sometimes cough on NUMERIC data type (I've never understood why, but I've seen it all too often!)

If you've got Entereprise Manager you can use the DESIGN tool (right click the table) to script your changes for you

Kristen
Go to Top of Page
   

- Advertisement -