I have table DateDim in database northwind_warehouse. I need to add new int primary key column named 'DateID' in this table with incrementing value starting with 109574 and increasing on 1 every new row. How can i do this if i have 1000 rows in table?
Asked
Active
Viewed 69 times
1
-
Why do you care what value your identity starts with? – Sean Lange Apr 26 '22 at 12:58
1 Answers
2
I think I understand you have no primary key in this table now, so you could do this
alter table DateDim add DateID int not null identity (109574, 1)
alter table DateDim add constraint PK_DateDim_ID primary key (DateID)

GuidoG
- 11,359
- 6
- 44
- 79
-
1You would need to add (109574, 1) to the identity so it will start with the number they want it to start with. – Sean Lange Apr 26 '22 at 12:58
-
1@SeanLange Oops I looked over that, corrected the answer. Thanks for noticing – GuidoG Apr 26 '22 at 13:00