How to concatenate NULL value with a string in SQL Server?# Database - 数据库
b*d
1 楼
This is part of my trigger code:
.....
select @a = FLD_A,
@b = FLD_B,
@c = FLD_C
from inserted
insert into TBL_A
values('A', @a+','[email protected]+','[email protected])
.....
Now the problem is FLD_B may not be populated and thus has a
NULL value in the table. the '+' operator returns NULL if a
NULL string is part of the concatenation. The only way to
get around is to add
if ISNULL(@b)
@b=' '
before the insert.
Is there any better way of doing it? There will be dozens of
fields like FLD_B, and I real
.....
select @a = FLD_A,
@b = FLD_B,
@c = FLD_C
from inserted
insert into TBL_A
values('A', @a+','[email protected]+','[email protected])
.....
Now the problem is FLD_B may not be populated and thus has a
NULL value in the table. the '+' operator returns NULL if a
NULL string is part of the concatenation. The only way to
get around is to add
if ISNULL(@b)
@b=' '
before the insert.
Is there any better way of doing it? There will be dozens of
fields like FLD_B, and I real