1

So far I've tried to modify the field with:

ALTER TABLE items ALTER COLUMN Item_ID int Identity(1,1)

but it doesn't work.

I have done some research on Google, but cannot solve it yet.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
appleduardo
  • 59
  • 2
  • 10
  • 3
    You can't alter the existing columns for identity, check this question: http://stackoverflow.com/questions/1049210/adding-an-identity-to-an-existing-column – Adel Khayata Nov 18 '14 at 04:08

1 Answers1

2

You did not mention that whether the items column already exists, or not. If it does, you cannot add identity constraint for the existing column.

read this

I believe that you have to create a new column using this query:

ALTER TABLE items
  ADD Item_ID int IDENTITY (1, 1)
Bob Gilmore
  • 12,608
  • 13
  • 46
  • 53
Sudhir kumar
  • 549
  • 2
  • 8
  • 31