leobelones
leobelones

Reputation: 598

Check Constraint Expression error

I'm trying to create a Check Constraint using SQL Server Management Studio 2012's wizard to allow a field to be null only if the tuple is not enabled, but I'm getting an Error validating constraint.

The expression I'm trying to use is this:

TransactionalMerchantId IS NOT NULL
OR
(TransactionalMerchantId IS NULL AND Enabled IS false)

My table is designed as this:

Table Merchant

Can someone help me figure out why this is happening?

Upvotes: 0

Views: 771

Answers (2)

Jake H
Jake H

Reputation: 1740

Try:

TransactionalMerchantId IS NOT NULL
OR
(TransactionalMerchantId IS NULL AND Enabled = 0)

Upvotes: 3

Andomar
Andomar

Reputation: 238048

is is for comparing with null only. Try:

[Enabled] = false

Upvotes: 0

Related Questions