Hi,
I am getting errors when I try to drop a column in sql server table.
Server: Msg 5074, Level 16, State 1, Line 1
The object 'DF__hdp_langu__langn__29572725' is dependent on column
'langname_ge'.
Server: Msg 4922, Level 16, State 1, Line 1
ALTER TABLE DROP COLUMN langname_ge failed because one or more objects
access this column.
I thought the object to be a constraint and tried dropping it first by
"alter table drop constraint" command.
But query analyser says that the concerned object is not a constraint. How
do I drop this object?
Thanks and Regards,
Celiacelia (celia.rexselin@.gmail.com) writes:
> I am getting errors when I try to drop a column in sql server table.
> Server: Msg 5074, Level 16, State 1, Line 1
> The object 'DF__hdp_langu__langn__29572725' is dependent on column
> 'langname_ge'.
> Server: Msg 4922, Level 16, State 1, Line 1
> ALTER TABLE DROP COLUMN langname_ge failed because one or more objects
> access this column.
> I thought the object to be a constraint and tried dropping it first by
> "alter table drop constraint" command.
> But query analyser says that the concerned object is not a constraint. How
> do I drop this object?
In this particular case you would do:
ALTER TABLE tbl DROP CONSTRAINT DF__hdp_langu__langn__29572725
A tip is that when you create tables is to always name your constraints
explicitly, that makes it easier to drop them. For instance:
CREATE TABLE a (a int NOT NULL,
b int NOT NULL CONSTRAINT df DEFAULT 12)
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspx|||You could search for dependents of the object you are trying to drop. For
example, if the object you are trying to drop is called 'ObjectName', then
try:
Select
ID ,
Object_Name( ID ) As Object ,
DepID ,
Object_Name( DepID ) As Dependent
From
SysDepends
Where
Id = Object_ID( 'ObjectName' )
"celia" <celia.rexselin@.gmail.com> wrote in message
news:Ooa$L1FFGHA.644@.TK2MSFTNGP09.phx.gbl...
Hi,
I am getting errors when I try to drop a column in sql server table.
Server: Msg 5074, Level 16, State 1, Line 1
The object 'DF__hdp_langu__langn__29572725' is dependent on column
'langname_ge'.
Server: Msg 4922, Level 16, State 1, Line 1
ALTER TABLE DROP COLUMN langname_ge failed because one or more objects
access this column.
I thought the object to be a constraint and tried dropping it first by
"alter table drop constraint" command.
But query analyser says that the concerned object is not a constraint. How
do I drop this object?
Thanks and Regards,
Celia|||Like everyone else has said, you have to drop the defaults and check
constraints first.
I have made a suggestion a while back on the feedback center. Please vote
for it :)
http://lab.msdn.microsoft.com/produ...14-4f026070abac
----
Louis Davidson - http://spaces.msn.com/members/drsql/
SQL Server MVP
"Arguments are to be avoided: they are always vulgar and often convincing."
(Oscar Wilde)
"celia" <celia.rexselin@.gmail.com> wrote in message
news:Ooa$L1FFGHA.644@.TK2MSFTNGP09.phx.gbl...
> Hi,
> I am getting errors when I try to drop a column in sql server table.
> Server: Msg 5074, Level 16, State 1, Line 1
> The object 'DF__hdp_langu__langn__29572725' is dependent on column
> 'langname_ge'.
> Server: Msg 4922, Level 16, State 1, Line 1
> ALTER TABLE DROP COLUMN langname_ge failed because one or more objects
> access this column.
> I thought the object to be a constraint and tried dropping it first by
> "alter table drop constraint" command.
> But query analyser says that the concerned object is not a constraint. How
> do I drop this object?
> Thanks and Regards,
> Celia
>
>
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment