Home Forums SQL Server 2008 T-SQL (SS2K8) Always set a Field to NULL - is a trigger the answer RE: Always set a Field to NULL - is a trigger the answer

  • UPDATE dbo.tblCustomer

    SET Extra=NULL

    FROM inserted tI

    WHERE dbo.tblCustomer.CID = tI.CID

    -- Worth checking for non empty?

    AND dbo.tblCustomer.Extra <> ''

    If you want the column to be set always to null, then you shouldn't be checking for an empty string.

    '' is not the same as null.

    Null equivalent would be

    AND dbo.tblCustomer.Extra is not null