Click here to Skip to main content
15,893,594 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
my table name is Accgroups in which i want to delete BranchID column when i start to delete it with below query it showing the error

ALTER TABLE AccGroups DROP COLUMN BranchID

"Msg 5074, Level 16, State 1, Line 1
The object 'IX_AccGroups' is dependent on column 'BranchID'.
Msg 4922, Level 16, State 9, Line 1
ALTER TABLE DROP COLUMN BranchID failed because one or more objects access this column.
"
Posted
Comments
Amalraj Ramesh 3-Mar-14 23:45pm    
Have refer this BranchID as foreign key reference
Amalraj Ramesh 3-Mar-14 23:49pm    
In management studio right click on table name and click on view dependencies
It will show the dependencies tables and sp
Member 8622273 4-Mar-14 0:10am    
in order to delete a column having dependencies, first you have to delete the constraint and then try to delete the column.

try this code

SQL
ALTER TABLE dbo.AccGroups DROP CONSTRAINT IX_AccGroups
ALTER TABLE dbo.AccGroups DROP COLUMN BranchID
 
Share this answer
 
Comments
Ankur\m/ 4-Mar-14 0:15am    
Note to OP: Just to give more detail - the error shows because there is a constraint named 'IX_AccGroups' on that column (probably an index) which is not allowing it to delete. You first need to drop that constraint and then you can delete the column.
5!
george4986 4-Mar-14 0:18am    
sorry i did't explained my solution
thanks Ankur ;-) gud luck.
i tries this code ....i succeded


ALTER TABLE dbo.AccGroups
DROP CONSTRAINT IX_AccGroups
EXECUTE sp_unbindefault N'dbo.AccGroups.IX_AccGroups'
ALTER TABLE dbo.AccGroups
DROP COLUMN BranchID


I thank to everybody...
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900