Hi, I would be grateful for some help with this because it is driving me mad! Maybe it's easy and I cant see the wood for the trees!I have a database which holds network kit. One table holds circuit information which can be of a type, DSL, MPLS, RXN etc. The circuit types "DSL", "MPLS", "RXN" are held in a reference table. There is certain information which some circuits must have and certain information which circuits should not have. For this particular scenario a circuit of type DSL can have a PSTN number associated with it. Any other circuit should throw a trigger to say no PSTN number is allowed. Recently, there has been a need to add a new circuit type DSLNonStd, which should also have a PSTN number associated with it, but the trigger is still getting thrown, when it shouldn't. The trigger is as follows:IF EXISTS (SELECT 1 FROM T_CIRCUIT c, T_CIRCUIT_TYPE ct WHERE c.circuit_type_id = ct.circuit_type_id AND ct.Name != 'DSL' AND ( MPLS_DSL_PSTN_Num IS NOT NULL) AND c.circuit_ID IN (SELECT circuit_ID from inserted)) BEGIN RAISERROR ('MPLS-DSL specific columns (MPLS_DSL_PSTN_Num) can only be populated for MPLS-DSL circuits', 16, 1) ROLLBACK TRAN RETURNEND;So I edited the code to the following:IF EXISTS (SELECT 1 FROM T_CIRCUIT c, T_CIRCUIT_TYPE ct WHERE c.circuit_type_id = ct.circuit_type_id AND (ct.Name != 'DSL' OR ct.Name != 'DSLNonStd') -- New Code to check for DSLNonStd circuit types too AND ( MPLS_DSL_Option IS NOT NULL OR MPLS_DSL_Product IS NOT NULL OR MPLS_DSL_PSTN_Num IS NOT NULL) AND c.circuit_ID IN (SELECT circuit_ID from inserted)) BEGIN RAISERROR ('MPLS-DSL specific columns (MPLS_DSL_Option, MPLS_DSL_Product, MPLS_DSL_PSTN_Num) can only be populated for MPLS-DSL circuits', 16, 1) ROLLBACK TRAN RETURNEND;But the trigger is still thrown. I can see why because using the or, it will always return all results from the circuit table like so:Circuit table contents:select * from t_circuit_type where (name != 'DSL' or name !='DSLNonStd')1 DSL MPLS NULL2 Dedicated MPLS NULL3 Resilient MPLS NULL4 Single RXN NULL5 Dual RXN NULL6 Split_Site RXN NULL7 DedNonStd MPLS NULL8 DSLNonStd MPLS NULL9 RXNNonStd RXN NULL
I am not sure how best to implement this, so that the trigger will only fire if the circuit type is not DSL or not DSLNonStd?Any ideas?