Home Check if a rule already exists

# Check if a rule already exists

user7594
1#
user7594 Published in September 19, 2018, 7:27 pm

When creating a rule for a user defined data type, how do I check if the rule already exists?

-- does rule exist?
CREATE RULE MyRule
AS @MyVar IN ('foo1', 'foo2')

• As an aside, rules are deprecated and will eventually be removed of SQL Server. You should use check constraints instead – Lamak Nov 13 '17 at 14:19
• How about checking exists in sys.objects tables? – Edward N Nov 13 '17 at 14:20
• @Lamak: Are u sure that I can use constraints for user defined types/table types? Look here: dba.stackexchange.com/questions/58348/… – Anil Bakirci Nov 13 '17 at 14:28
• @Schwammkopf I don't really understand your question, but yes, check constraints can (I mean, whay else would the exist?) be used in user defined tables. The link you posted just shows wrong syntax being used – Lamak Nov 13 '17 at 14:31