0

I have the following table:

Table : Test1

create table test1
(
  ID int
);

Note: I have a data on this table and I don't want to lose it.

Now I want to alter the column data type to INT IDENTITY for which I am using the following script.

My Try:

ALTER TABLE test1
ALTER COLUMN ID INT IDENTITY(1,1);

Which is throwing an error:

Incorrect syntax near the keyword 'IDENTITY'. 
Community
  • 1
  • 1
MAK
  • 6,824
  • 25
  • 74
  • 131
  • 1
    Identity is not a data type, it's a property. AFAIK you can't set it to an existing column if it already have data. – Zohar Peled Aug 20 '15 at 15:11
  • 1
    You can't add the Identity option to an existing column. You can add a new column to the table with INT IDENTITY(1,1). However this will lock the table for the duration of the operation. – Amir Pelled Aug 20 '15 at 15:28

0 Answers0