I have a table which already consists a number of records. The table has a column named 'id' of integer type and I have already inserted unique values in id column for all the records in the table.
Now I need to set IDENTITY constraint on the 'id' column so that in any new record added to the table, the value of id column gets inserted automatically incremented from the last value added to the column.
The create table query of the table is like follows:
create table Table1 (
Column1 varchar(255) not null,
Column2 varchar(254) not null,
Column3 int not null,
id int ,
PRIMARY KEY CLUSTERED ( id ) on 'default'
)
I insert data into the table using following query:
Insert into Table1 (Column1, Column2, Column3, id) values("abc","def",12,1)
But when I try to execute following Alter table query on my sybase database it returns an error "Incorrect Syntax near 'IDENTITY'"
ALTER TABLE Table1 MODIFY id int IDENTITY DEFAULT AUTOINCREMENT NOT NULL
Can anyone point me in the right direction about, how to apply IDENTITY constraint on a column which already has data?