[英]How to get names of all SQL Server Defaults and Rules
I'm trying to write a query to get the names of all Rules and Defaults in the database so I can programatically drop all of them from a database without having to know their names. 我正在尝试编写查询以获取数据库中所有规则和默认值的名称,以便可以以编程方式从数据库中删除所有规则和默认值,而不必知道它们的名称。
They don't seem to be contained in sys.objects
, though - so where can I find them? 但是,它们似乎似乎不包含在sys.objects
-那么在哪里可以找到它们?
Try this 尝试这个
SELECT *
FROM sys.objects
WHERE type = 'r' -- to filter rules
OR ( parent_object_id = 0 -- to restrict default constraints
AND type = 'd' ) -- to filter defaults
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.