Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 ALTER TABLE

Author  Topic 

daya_nirvana
Starting Member

3 Posts

Posted - 2008-09-18 : 08:10:08
I am trying to alter a column from my table using

ALTER TABLE MM_MAT_TRANS_T ALTER COLUMN DOC_ITEM_NO NUMERIC(5,0)

but when i do this i get the folloeing error

Msg 5074, Level 16, State 1, Line 1
The object 'PK_MM_MAT_TRANS_T' is dependent on column 'doc_item_no'.
Msg 4922, Level 16, State 9, Line 1
ALTER TABLE ALTER COLUMN doc_item_no failed because one or more objects access this column.

This is probably coz of the FK relation with other tables how to over come this issue

-Daya

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2008-09-18 : 08:20:13
drop the constraint
alter both columns
re-add the constraint

Be One with the Optimizer
TG
Go to Top of Page

daya_nirvana
Starting Member

3 Posts

Posted - 2008-09-18 : 08:43:10
Thanks I have already done that and its working. But is there an way to do it without dropping constraints....
Go to Top of Page

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2008-09-18 : 08:44:14
No. You can disable constraints though.
Go to Top of Page

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2008-09-18 : 09:21:08
You can also add (or re-enable) them with NOCHECK. That would be a virually instantaneous action if you are concerned with the time it takes to re-apply them on large tables. Of course as the name implies it won't catch any value violations that may have been introduced when the constraint was inactive.

Be One with the Optimizer
TG
Go to Top of Page

daya_nirvana
Starting Member

3 Posts

Posted - 2008-09-18 : 09:40:53
thanks
Go to Top of Page
   

- Advertisement -