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
 General SQL Server Forums
 New to SQL Server Programming
 Error Message when trying to modify field

Author  Topic 

kathyc
Starting Member

9 Posts

Posted - 2008-08-15 : 19:01:40
Hello,

I need to alter the field width of the sportID column from char(2) to char(3)and wrote this code.

ALTER TABLE sport ALTER COLUMN [sportID] char(3);

I ran the code and got the following error:

Warning: odbc_exec() [function.odbc-exec]:
SQL error: [Microsoft][ODBC SQL Server Driver]
[SQL Server]The object 'PK_sport' is
dependent on column 'sportID'.,

How do I resolve this issue?

Thanks.

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2008-08-15 : 19:03:40
drop the constraint, alter the column then create the constraint again


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2008-08-16 : 01:10:49
Disable constraints if you are in SQL 2005 and Enable after you are done.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-08-16 : 01:11:15
script out the constraintfrom management studio/Query Analyser and use it for dropping & recrreating.
Go to Top of Page
   

- Advertisement -