Archive

Posts Tagged ‘alter’

SQL: Alter script to change the Primarykey Column datatype

February 23, 2015 Leave a comment

–This will drop the primary key constraint
ALTER TABLE [pTARGET_TYPE] DROP CONSTRAINT PK_TARGET_TYPE

–Alter datatype
ALTER TABLE [TARGET_TYPE] ALTER COLUMN [TARGET_TYPE_ID] INT NOT NULL

–Add Primary key constraint
ALTER TABLE [TARGET_TYPE] ADD CONSTRAINT PK_TARGET_TYPE PRIMARY KEY ([TARGET_TYPE_ID])