Solved

Cannot drop column because of object reference

Posted on 2013-06-13
6
433 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
Free Webinar: AWS Backup & DR

Join our upcoming webinar with experts from AWS, CloudBerry Lab, and the Town of Edgartown IT to discuss best practices for simplifying online backup management and cutting costs.

 

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

Technology Partners: 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

Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
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.

749 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