views:

77

answers:

2

i have inherited a database application from someone else and there are a few tables that dont have any primary keys. I want to add a new column into an already existing table and have it autonumber (starting from 1). how would i go about doing this?

+2  A: 

The SQL Server syntax is:

ALTER TABLE SomeTable ADD
    ID int NOT NULL IDENTITY(1, 1),
    CONSTRAINT PK_SomeTable PRIMARY KEY [NON]CLUSTERED (ID)
Aaronaught
A: 

"i need to delete a number of rows and the only way i can do it now is by using the timestamp field. It would be much easier if i could say "delete from tableA where id = 100""

And how would you decide which id's to delete ?

Erwin Smout
i know which rows that i need to delete when i look at the data . . it was just a pain to delete rows without an easy differentiated piece of data
ooo