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 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy