Solved

Cannot drop column because of object reference

Posted on 2013-06-13
6
420 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
Comment Utility
The error message should tell you what object is causing the error.
0
 

Author Comment

by:GeneralDigitalITS
Comment Utility
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
Comment Utility
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
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 

Author Comment

by:GeneralDigitalITS
Comment Utility
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
Comment Utility
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
Comment Utility
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

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Join & Write a Comment

Having an SQL database can be a big investment for a small company. Hardware, setup and of course, the price of software all add up to a big bill that some companies may not be able to absorb.  Luckily, there is a free version SQL Express, but does …
JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

762 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now