How do I drop a column with object dependencies in SQL Server 2008?(如何在 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 失败,因为一个或多个对象访问此列.
ALTER TABLE DROP COLUMN fkKeywordRolleKontakt failed because one or more objects access this column.
我已经尝试找到默认约束,如下所述: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 Server 管理器中),选择修改"并删除该列来生成一个脚本来删除该列.然后表设计器 >Generate Change Script 生成了必要的命令:
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 失败,因为一个或更多对象访问此列.
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 > Columns > fkKeywordRolleKontakt)(在 MSSQL Server 管理器中),选择修改并删除列.然后 Table Designer > Generate Change Script 生成了必要的命令:
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 中删除具有对象依赖关系的列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何在 SQL Server 2008 中删除具有对象依赖关系的列?
- 如何使用 pip 安装 Python MySQLdb 模块? 2021-01-01
- 导入具有可变标题的 Excel 文件 2021-01-01
- 如何将 SonarQube 6.7 从 MySQL 迁移到 postgresql 2022-01-01
- 如何将 Byte[] 插入 SQL Server VARBINARY 列 2021-01-01
- 使用 Oracle PL/SQL developer 生成测试数据 2021-01-01
- 远程 mySQL 连接抛出“无法使用旧的不安全身份验证连接到 MySQL 4.1+"来自 XAMPP 的错误 2022-01-01
- 以一个值为轴心,但将一行上的数据按另一行分组? 2022-01-01
- 在SQL中,如何为每个组选择前2行 2021-01-01
- 更改自动增量起始编号? 2021-01-01
- SQL 临时表问题 2022-01-01
