• Sean Lange (10/3/2013)


    SrcName (10/3/2013)


    if you define constraint then you don't have situation for update,

    because there will be no rows with impaired restriction, unless you disable constraint.

    ???

    I am curious how you would meet the requirements of the OP using a constraint.

    Here is the sample table with some data.

    CREATE TABLE usTab1

    (

    Col1 INT IDENTITY(1,1) NOT NULL PRIMARY KEY,

    Col2 Tinyint DEFAULT (0) NOT NULL,

    Col3 NVARCHAR(30) NOT NULL

    )

    insert usTab1

    select 0, 'Allows change' union all

    select 1, 'Can''t change'

    select * from usTab1

    How can you write a constraint that won't allow an update to Col3 when the value of Col2 = 0?

    i don't say that this may solve with constraint, and there isn't way to do that.

    I just think step behind on this request [b]I must include a constraint over Col3, that column can be update only if Col2 is 0 other way don't allow[/b], if we define constraint on table for this requirement there would't be any update.

    constraint literally