简体   繁体   中英

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?

规则和默认

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 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM