首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

求条sql函数:规则字符串怎么生成表

2012-03-15 
求条sql函数:规则字符串如何生成表?如传入字符串“a , b , c , d”如何让它变成:selectaunionselectbunionse

求条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

热点排行
Bad Request.