Check constraint with condition
I need a constraint against records created/amended that have an invoicenumber beginning with CN%, ensure the analysiscode is not like the value ' %'. As some people are entering spaces in the analysiscode.
Anyway this logic does not work ...
alter table invoicesalesanalys
add constraint check_anaLYSISCODE
check (ANALYSIS1CODE not like ' %' where invoicenumber like 'CN%')
I need a way of tackling it - can anyone help?
Once you have eliminated all of the impossible,
whatever remains however improbable,
must be true.