Solved

Cannot drop column because of object reference

Posted on 2013-06-13
6
430 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
  • 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
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 

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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
T-SQL: Episode III - Revenge of The Dude 24 53
Simple SQL query from two tables 13 54
CPU high usage when update statistics 2 30
SQL Query assistance 16 26
Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.

777 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