Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 452
  • Last Modified:

Cannot drop column because of object reference

Greetings,
I have an issue with a stored procedure that is refusing to drop a column because of a dependency or object reference. We have reviewed all of the constraints, defaults and indexes. Is there somewhere less obvious we should look? Is there a way to have the server print the referencing object ID that we are having trouble locating? We are using SQL Server 2012. Thanks.
0
GeneralDigitalITS
Asked:
GeneralDigitalITS
  • 3
  • 3
1 Solution
 
Anthony PerkinsCommented:
The error message should tell you what object is causing the error.
0
 
GeneralDigitalITSAuthor Commented:
The error message is very non-specific:

ErrorNumber: 4922
ErrorSeverity: 16
ErrorState: 9
ErrorMessage: ALTER TABLE DROP COLUMN ColumnName failed because one or more objects access this column.

Where is it telling me which object is causing the error?
0
 
Anthony PerkinsCommented:
Check out this thread and hopefully you will see what I mean:
http://stackoverflow.com/questions/2253185/how-do-i-drop-a-column-with-object-dependencies-in-sql-server-2008

If you are still having trouble post the query that is causing the problem as well as all the schemas for all the associated tables.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
GeneralDigitalITSAuthor Commented:
Thanks again for your post. You have actually indirectly led us to the solution. I noticed somewhere in that thread that someone had said to just go drop the column from the table designer. So we did just that and it turns out that there were two views that were calling the  WITH SCHEMABINDING function. Apparently this creates a referential constraint between the column and the view. Hopefully this will save someone a little time someday. Thanks.
0
 
GeneralDigitalITSAuthor Commented:
This solved our problem, the link in the expert comment led us to the correct solution. The actual solution is our comment, however, your system will not let me assign points to it, so I cannot select it as a solution.
0
 
Anthony PerkinsCommented:
I noticed somewhere in that thread that someone had said to just go drop the column from the table designer.
And that explains why you were not seeing the error message.  All the "Designer" tools are crippled at best and for the most part should be avoided or at least you should point out that you are still using them.

Apparently this creates a referential constraint between the column and the view.
That is true.  You cannot modify any table that is used my any indexed VIEW (it has WITH SCHEMABINDING)

The actual solution is our comment, however, your system will not let me assign points to it, so I cannot select it as a solution.
Sure it does.  It is all explained in the Help
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now