• dwain.c (10/6/2013)


    Sean Pearce (10/4/2013)


    Dwain, that constraint won't allow you to disable editing.

    UPDATE #usTab1

    SET Col2 = 1

    WHERE Col1 = 1;

    GO

    Actually Sean, I never said it would. The OP wanted to disable changing Col3 based on the value of Col2. The CONSTRAINT I provided seems to do that.

    Having said that, I consider this sort of a "stupid SQL DDL trick" and I'm not sure I'd ever use it myself. A trigger is probably the better way to do it because of the additional control it provides.

    Dwain, I meant no offence but simply wanted to point out to the OP that the constraint wouldn't allow editing Col2.

    Having said that, I like your "stupid SQL DDL trick" and thought it was quite clever. I would also use a trigger, it is definitely the better way to implement this type of constraint.

    The SQL Guy @ blogspot[/url]

    @SeanPearceSQL

    About Me[/url]