Forum Discussion

mesan98's avatar
mesan98
Copper Contributor
Mar 25, 2021

Alter a primary key column as IDENTITY

Hi there,

 

I have a SQL Server table named Users (ID, Name, LoginDate, Password, Email) with some records in it. But when I created it I forgot to Auto Increment its ID which is the primary key. Now I am trying to alter the ID column to turn in into an IDENTITY or AUTO-INCREMENT attribute but I failed.. Is there a way I can do that plz ?

 

Thanks in advance !

  • olafhelper's avatar
    olafhelper
    Bronze Contributor

    mesan98, you can not alter an existing column to IDENTITY.

     

    You have to either recreate the table or add an additional column with IDENTITY property.

     

    Olaf

Resources