sql,怎样遍历字符串

declare @idx int, @str nvarchar(1000)
set @str = '我的字符串'
set @idx = 1
while @idx <= len(@str)
begin
 PRINT substring(@str, @idx, 1)-- 取得@idx所在的这个字符
 set @idx = @idx + 1
end

-----------------------------------------------------------------------
结果:

我
的
字
符
串
 

 

posted on 2012-05-28 17:07  zhuhai  阅读(270)  评论(0编辑  收藏  举报

导航

我的百度空间