如何检索外键约束的状态?
我有用于获取所有约束名称的 SQL 查询,但不确定如何获取其状态,例如是否启用/禁用?
SELECT OBJECT_NAME(OBJECT_ID) AS NameofConstraint,
SCHEMA_NAME(schema_id) AS SchemaName,
OBJECT_NAME(parent_object_id) AS TableName,
type_desc AS ConstraintType,*
FROM sys.objects
有什么帮助吗?
I have the SQL query for getting all the constraint names, but not sure how to get its status like whether it is enabled/disabled?
SELECT OBJECT_NAME(OBJECT_ID) AS NameofConstraint,
SCHEMA_NAME(schema_id) AS SchemaName,
OBJECT_NAME(parent_object_id) AS TableName,
type_desc AS ConstraintType,*
FROM sys.objects
Any help?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用 OBJECTPROPERTY(OBJECT_ID('FK_foo_bar', 'CnstIsDisabled')
或
使用 sys.foreign_keys 其中有一列“is_disabled”
Use
OBJECTPROPERTY(OBJECT_ID('FK_foo_bar', 'CnstIsDisabled')
OR
Use sys.foreign_keys which has a column "is_disabled"