Wednesday, 21 August 2013

Increase primary-key column size having numerous dependencies

Increase primary-key column size having numerous dependencies

Scenario: I have a table (Customer). It has composite key out of which one
is "Relationship_num" which has a size varchar(30).There is ample data in
it. And 21 dependent tables.
Problem: Inserting a record which has relationship_num greater than the
size of the column. So now i want to increase its size.
Unsuccessful Work around: When I made an attempt to alter the size, it
displays error: The object 'PK_CUSTOMER' is dependent on column
'RELATIONSHIP_NUM'.And 21 other errors of those tables which has the
dependency on Customer table.
Then I tried to drop 'PK_CUSTOMER':
ALTER TABLE [dbo].[CUSTOMER] DROP CONSTRAINT [PK_CUSTOMER]
which resulted in following error:
The constraint 'PK_CUSTOMER' is being referenced by table 'some-table',
foreign key constraint 'RefCUSTOMER447'.Could not drop constraint. See
previous errors.
Now making scripts(create and drop) of all these constraints could me
cumbersome.
Plz help me out with this!

No comments:

Post a Comment