分拆字符串
2009-05-22 18:38
190 查看
有一字段值为:a,b,c ,想要得到如下:
id name 1 a 2 b 3 c
在SQL中如何实现呢? ----------------------------------------------- declare @str varchar(8000)
set @str = 'a1,b1,c2,d1,e3,f5'
set @str = 'select name='''+replace(@str,',','''union all select ''')+'
'''
--如果要编号的话,那就这样。
--set @str='select id=identity(int,1,1),name into #temp from ('+@str+') a --select * from #temp drop table #temp'
exec(@str) /* name ---- a1 b1 c2 d1 e3 f5
*/
相关文章推荐
- 分拆统计字符串
- [导入]字符串分拆查询
- 各种字符串分拆处理函数.sql
- oracle 10g 使用REGEXP_SUBSTR 分拆字符串
- 短信字符串分拆
- 字符串分拆查询
- 短信字符串分拆
- 字符串分拆查询
- 字符串分拆查询
- [导入]短信字符串分拆
- SQL开发应用实例存储过程——各种字符串分拆处理函数
- 短信字符串分拆
- 字符串分拆查询
- 分拆字符串求和
- 利用php的explode函数将字符串按分隔符(比如空格)分拆并组装在数组中-----要考虑连续空格问题
- 分拆统计字符串
- 分拆统计字符串
- Oracle 10g 使用REGEXP_SUBSTR 分拆字符串 (转)
- sqlserver 字符串分拆 语句
- 今天周末,在家休息,从CString派生,写了个CExtendString类,增加了一个Splite函数用于分拆字符串。