如何在SQL Server 2008中删除具有对象依赖关系的列? [英] How do I drop a column with object dependencies in SQL Server 2008?

查看:3930
本文介绍了如何在SQL Server 2008中删除具有对象依赖关系的列?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试删除列时,我正在获取的错误消息:

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


对象'defEmptyString'依赖于列'fkKeywordRolleKontakt '。

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

消息5074,级别16,状态1,行43

Msg 5074, Level 16, State 1, Line 43

ALTER TABLE DROP COLUMN fkKeywordRolleKontakt failed because一个或多个对象访问此列。

ALTER TABLE DROP COLUMN fkKeywordRolleKontakt failed because one or more objects access this column.

我已经尝试找到默认约束,如下所述:
< a href =http://stackoverflow.com/questions/314998/sql-server-2005-drop-column-with-constraints>具有约束的SQL Server 2005下拉列

I have already tried to find the default constraints, as described here: SQL Server 2005 drop column with constraints

遗憾的是没有任何成功:(返回的行是:

Unfortunately without any success :( The line returned is:

fkKeywordRolleKontakt 2 814625945 0 defEmptyString

我不能删除 fkKeywordRolleKontakt defEmptyString

摆脱这种依赖关系的正确方法是什么?

What is the correct way to get rid of this dependency?

编辑:也许这也很重要。列fkKeywordRolleKontakt的类型为udKeyword(nvarchar(50)),默认为 dbo.defEmptyString

Perhaps this is of importance too. The column fkKeywordRolleKontakt is of type udKeyword (nvarchar(50)) with default dbo.defEmptyString.


编辑2:解决

我可以解决问题现在。对不起,我没有复制完整的错误消息,这是:

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

消息5074,级别16,状态1,行1

对象'defEmptyString'依赖于列'fkKeywordRolleKontakt'。

消息5074,级别16,状态1,行1

对象' FK_tlkpRolleKontakt_tlkpKeyword'依赖于列'fkKeywordRolleKontakt'。

消息4922,级别16,状态9,行1

ALTER TABLE DROP COLUMN fkKeywordRolleKontakt失败,因为一个或多个对象访问此列。

我可以通过右键单击列条目(dbo.tlkpRolleKontakt> Columns> fkKeywordRolleKontakt)生成一个脚本来删除列(在MSSQL服务器管理器中),选择修改和删除列。然后表设计器>生成更改脚本生成必要的命令:

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

就是这样:)

推荐答案

我现在可以解决问题。对不起,我没有复制完整的错误消息,这是:

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

消息5074,级别16,状态1,行1

对象'defEmptyString'依赖于列'fkKeywordRolleKontakt'。

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


消息5074,级别16,状态1,行1
对象
'FK_tlkpRolleKontakt_tlkpKeyword'依赖于列
'fkKeywordRolleKontakt'。
消息4922,级别16,状态9,行1 ALTER TABLE DROP COLUMN fkKeywordRolleKontakt failed because one or
更多的对象访问此列。

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.

我可以通过右键单击列条目来生成一个脚本来删除列(dbo.tlkpRolleKontakt>列> fkKeywordRolleKontakt)(在MSSQL服务器管理器中),选择修改和删除列。然后表设计器>生成更改脚本生成必要的命令:

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

这篇关于如何在SQL Server 2008中删除具有对象依赖关系的列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆