How do I drop a column with object dependencies in SQL Server 2008?

后端 未结 5 1353
北恋
北恋 2021-01-01 11:30

The error message I\'m obtaining when trying to drop a column:

The object \'defEmptyString\' is dependent on column \'fkKeywordRolleKontakt\'.

Msg

5条回答
  •  时光说笑
    2021-01-01 12:05

    I could solve the problem now. I'm sorry, I did not copy the full error message, which was:

    Msg 5074, Level 16, State 1, Line 1
    The object 'defEmptyString' is dependent on column 'fkKeywordRolleKontakt'.

    Msg 5074, Level 16, State 1, Line 1
    The object 'FK_tlkpRolleKontakt_tlkpKeyword' is dependent on column 'fkKeywordRolleKontakt'.
    Msg 4922, Level 16, State 9, Line 1 ALTER TABLE DROP COLUMN fkKeywordRolleKontakt failed because one or more objects access this column.

    I could generate a script to drop the column by right-clicking on the column entry (dbo.tlkpRolleKontakt > Columns > fkKeywordRolleKontakt) (in MSSQL Server Manager), selecting Modify and deleting the column. Then Table Designer > Generate Change Script generated the necessary commands:

    ALTER TABLE dbo.tlkpRolleKontakt
        DROP CONSTRAINT FK_tlkpRolleKontakt_tlkpKeyword
    EXECUTE sp_unbindefault N'dbo.tlkpRolleKontakt.fkKeywordRolleKontakt'
    ALTER TABLE dbo.tlkpRolleKontakt
        DROP COLUMN fkKeywordRolleKontakt
    

提交回复
热议问题