August 2, 2012 at 6:00 pm
Hi All,
I have a column which is a primary key. It was mistakenly made NCHAR which actually shoud have been int. Now I am trying to change the data type by using the alter table command I get the following errror
Msg 5074, Level 16, State 1, Line 2
The object 'PK_INK_NEXT_OPERATION' is dependent on column 'operation_id'.
Msg 4922, Level 16, State 9, Line 2
ALTER TABLE ALTER COLUMN operation_id failed because one or more objects access this column.
Shoud I drop the primary key make the change and then re create the Primary key??
August 2, 2012 at 11:15 pm
Yes, smth like this:
alter table MyTable drop constraint PK_INK_NEXT_OPERATION;
alter table MyTable alter column operation_id int not null
alter table MyTable add constraint PK_INK_NEXT_OPERATION primary key (operation_id);
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply