I already have a table created with some columns. Now I am trying to add a column with a primary key. I right click the columns, add new column. It lets me add column name, data type as int. Right click on that and setting it to primary key.
When I save this, I get an error
Unable to modify table.
ALTER TABLE only allows columns to be added that can contain nulls, or have a DEFAULT definition specified, or the column being added is an identity or timestamp column.
Can someone let me know how to alter an already created table? I need to add a primary key to it with auto increment.
You need to do 4 steps to get this done:
Step 1 - create the column
Step 2 - make it the primary key
Step 3 - bring up the column or table properties
Step 4 - define it to be an IDENTITY
column
Only now - save the changes. And now, it should work just fine.