views:

140

answers:

2

Can i use if else under a check constraint.

Can i use check constraint using a variable

need xplanation with eg.

+3  A: 

Your question is a bit vague. What are you trying to do with the IF...ELSE? Check constraints aren't processed code, they're part of the table definition - there is no control flow and no variables. You can use a user-defined function in check constraints, which may be what you're after, but it's hard to tell from your question.

Tom H.
+2  A: 

You cannot use IF/ELSE, but you can use inline conditionals: CASE WHEN

Cade Roux