无法在 SQL Server 2017 中的列错误中插入 NULL 值

Cannot insert NULL value in column error in SQL Server 2017

这是我的查询

insert into membre (code) 
select code = case when trig = '' then 'toto' else case when trig is null 'titi' end end
from test

我想将此结果插入到 table 测试中,但它会向我显示此错误 .你能帮我掌舵吗?

我怀疑你想要下面的逻辑

insert into membre(code)
select case 
    when trig = '' then 'toto'
    when trig is null then 'titi'
    else trig
end
from test

这会将 test(trig) 插入到 membre(code),同时将空字符串转换为 'toto' 并将 null 值转换为 'titi'