0
我需要这样做。根据case/when语句将多个值插入到表结构中
Declare @something varchar(100)
Declare @tempdata TABLE (temp varchar(100))
INSERT INTO @tempdata (temp) select case
when @something is null then 'temp1','temp2'
else @something
end
select * from @tempdata
看起来像是在条件为null时,根据条件为null,将多个值插入@tempdata数组无效。
未设置@something时,如何向@tempdata添加多个值。
我试着这样做
when @something is null then 'temp1,temp2'
,然后试图通过分隔符逗号分割,然后添加到@tempdata,但在SQL分裂看起来并不容易。
感谢您的期待。
你可能最好把你的每个案例分成一个'if'-'else'结构。 –
谢谢。我做到了。它的工作。有没有办法让上述工作在case..when语句中。现在只是好奇。 :) – user3606175