-2

How to remove identity on primary key column in SQL Server 2016?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Naga
  • 17
  • 1
  • 1
  • 2
  • 6
    Possible duplicate of [Remove Identity from a column in a table](https://stackoverflow.com/questions/8230257/remove-identity-from-a-column-in-a-table) – TZHX May 22 '18 at 15:57

2 Answers2

3

Create a new column, copy the data, drop original column

alter table yourtable
add newcolumn int

update yourtable
set newcolumn=oldcolumn

alter table yourtable
drop column oldcolumn
Daniel Marcus
  • 2,686
  • 1
  • 7
  • 13
-4

you can't remove Identity on a primary key column. It is by default gets created when you choose a column as Primary. You need to do alternatives which I don't recommend on project tables.

1) Drop the primary key with cascade option (You will lose the links to child tables)

2) - You need to create another column with a different name in the same table. - copy that data into newly created column - Delete the primary key column.
this will leave orphan records in child tables that are being referenced.