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?
views:
77answers:
2
+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
2010-04-04 03:47:16
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
2010-04-04 20:41:45
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
2010-04-04 21:54:34