求条sql函数:规则字符串如何生成表?
如传入字符串 “ 'a ', 'b ', 'c ', 'd ' ”
如何让它变成:
select 'a '
union
select 'b '
union
select 'c '
union
select 'd '
谢谢大侠指教~
------解决方案--------------------declare @s varchar(200)
set @s= ' ' 'a ' ', ' 'b ' ', ' 'c ' ', ' 'd ' ' '
select @s= 'select '+replace(@s, ', ', ' union select ')
print @s