SQL Server : want a column to be nullable only for existing and newly created rows -


is possible make column can null beginning, once has been set non-null value can never reset null?

i'm guessing might possible update constraint using both inserted , deleted table, seems complicated given goal of task.

bonus question: since doesn't seem easy this, sign of bad design (on part of / sql server)?

since you're allowing filed null when row inserted, you'll have use trigger update

create trigger trigger1 on table1 update  begin       set nocount on      declare @field1 varcahr(max)      select @field1 = field1 inserted       if @field1 null      begin          raiserror('a null values not allowed', 15, 1)          rollback      end end 

Comments

Popular posts from this blog

c++ - No viable overloaded operator for references a map -

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - Cannot secure connection using TLS -