0

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?

Rules and Defaults

Catchwa
  • 5,845
  • 4
  • 31
  • 57
  • http://stackoverflow.com/questions/14229277/sql-server-2008-get-table-constraints – squillman Jan 19 '17 at 03:47
  • @squillman both of the answers there return no rows for me. I think that they only show where the rules/defaults are used, as opposed to the actual definitions themselves – Catchwa Jan 19 '17 at 04:01

1 Answers1

1

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 
Pரதீப்
  • 91,748
  • 19
  • 131
  • 172