Updating identity column sql server 2016
It allows a unique number to be generated when a new record is inserted into a table. However, once the table is created, we cannot use Alter command to add an identity to the table.Use Alter command to add an identity will throw an exception.
Finally, we have to define the fields as NOT NULL and Primary Key, or even as Identity, and alter the foreign key in detail table, or add a new one.
Create a new database table using the SQL Server Management Studio GUI.
In SQL Server, you can create a new database table either via the SQL Server Management Studio graphical user interface (GUI), or by running an SQL script.
This is the case, if we have a Primary key set on the column that we are trying to add an identity.
Set Identity to Non Primary Field However, if the column ‘Id’ was not set as the Primary key, we can set the identity from the Design mode, as shown below.
I added a new column in the Table X This column "cn" has to be unique and mandatory, but old data don't have any value.