简体   繁体   中英

Can we use “if else” in “Check” constraint in sql server

Can i use if else under a check constraint.

Can i use check constraint using a variable

need xplanation with eg.

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.

您不能使用IF/ELSE ,但是可以使用内联条件: CASE WHEN

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