SQL query error

Hello there,

I am trying to alter a tables col and i get this error

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

the query i am running is
ALTER TABLE pdu ALTER COLUMN nper nvarchar(128) COLLATE SQL_Latin1_General_CP1_CI_AS NULL

Open in new window

I am using sql server 2008

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Leo TorresSQL DeveloperCommented:
You need to drop the constraint on the column then do the alter
zolfAuthor Commented:
Thanks for your feedback.
OK, i dropped the contraint and then i was able to alter the col. Is that contraint needed. I mean do i need to create that contraint again or ignore it. what is this contraint thingy.
Deepak ChauhanSQL Server DBACommented:
According to the name 'DF__pdu__nper__2E1BDC42'' , I guess it is default constraint, it means if you are not inserting the value for this column sql server insert a default value eg. 'xyz'.

This is according to your database design and application requirement it might be mandatory and needs to be created again. But first check the constraint script if you have generated before drop.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Leo TorresSQL DeveloperCommented:
You may want to put the constraint back yes it must have been there for a reason.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.