Sql server 2012 基于case/when语句向表结构中插入多个值
我必须这样做Sql server 2012 基于case/when语句向表结构中插入多个值,sql-server-2012,Sql Server 2012,我必须这样做 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 when @someth
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
when @something is null then 'temp1,temp2'
如果条件为null,则在@tempdata数组中插入多个值无效
when @something is null then 'temp1,temp2'
当@something未设置时,如何向@tempdata添加多个值
when @something is null then 'temp1,temp2'
我试过这么做
when @something is null then 'temp1,temp2'
然后尝试用分隔符逗号将其拆分,然后添加到@tempdata,但在sql中拆分看起来并不容易
when @something is null then 'temp1,temp2'
谢谢查看。您需要使用IF语句,然后插入SELECT。。。团结所有人
when @something is null then 'temp1,temp2'
你最好把你的每一个案例分成一个if-else结构。谢谢。我做到了。它成功了。是否有一种方法可以使上述方法在一个case..when语句中起作用。现在只有古玩了