What is the best way (low impact/low risk) to change a primary key field from SMALLINT to INT? The field is configured to use "Identity Increment" to auto-increment.
I'm starting with the following SQL:
ALTER TABLE category_types ALTER COLUMN id INT NOT NULL;
However, it generates the following error:
ALTER TABLE ALTER COLUMN id failed because one or more objects access this column.
What else is required? Do I need to drop the keys then recreate them? Will this impact the auto-incrementation?
Note: the table doesn't have too many rows, so the performance of the solution is not critical.
This is output from sql server management studio but should be of some help. It involves creating a temporary table and then copying existing data to the new table. Dropping the original table and renaming the temp table. If the table was empty, it wouldn't do this and could just modify the original table.
SET IDENTITY_INSERT [table] ON/OFF
allows you to set the identity column when inserting.