How to change database primary key field with a foreign key constraint

Today I needed to increase a varchar database from 2 position to 50 positions. At first I thought this would be easy, just make a change script like this: 1: ALTER TABLE tb_Categories ALTER COLUMN Code varchar(50) not null After running in SSMS I got two error messages back: Msg 5074, Level 16, State 1, Line 1 The object 'FK_CategoryCode' is dependent on column 'Code'. Msg 4922, Level 16, State 9, Line 1 ALTER TABLE ALTER COLUMN Code failed because one or more objects access this column. Oops.. The Code field is used as a primary key here and ref... [More]