I have a table in database (Azure Data Studio)and while writing the create table script I forgot to add the primary key constraint. In order to add primary key constraint I have to alter the table and before that the default NULL has to be removed from that particular column tow which I am going to mark as primary key.
My create table scripts looks like this: Crete Table dbo.employee( employeeID varchar(120) NULL, employeeName varchar(50) NULL, employeePhone Integer NULL )
So I need to create a primary key constraint on employeeID table in Azure Data Studio so I was using the general script like:
ALTER TABLE [dbo].[employee] ADD PRIMARY KEY CLUSTERED ( [employeeID ] ASC )WITH (STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ONLINE = OFF, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY] GO
The above statement is giving me expected error because the **employeeID **is set to NULL as default.The error I am getting while alter the column is this:[enter image description here][enter image description here][1] Can anyone help me to resolve this issue and add the primary key on that column.