Skip to content
Advertisement

Add check constraint related to other column

My table structure is as below

I want to add a constraint to this table where only if IsActive=1, GoSequence value can be change.

If IsActive=0, GoSequence stays 0.

Any help is appreciated. Thanks!

Advertisement

Answer

Probably the simplest way of expressing that is that either GoSequence must be 0 or IsActive must be 1.

So your constraint could look like this:

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement