Solved

Cannot drop column because of object reference

Posted on 2013-06-13
6
438 Views
Last Modified: 2013-06-18
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
Comment
Question by:GeneralDigitalITS
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 39245250
The error message should tell you what object is causing the error.
0
 

Author Comment

by:GeneralDigitalITS
ID: 39253061
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
 
LVL 75

Accepted Solution

by:
Anthony Perkins earned 500 total points
ID: 39254114
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
 Watch the Recording: Learning MySQL 5.7

MySQL 5.7 has a lot of new features. If you've dabbled with an older version of MySQL, it is definitely worth learning.

 

Author Comment

by:GeneralDigitalITS
ID: 39256370
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
 

Author Closing Comment

by:GeneralDigitalITS
ID: 39256381
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
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 39258194
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

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!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

615 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question