Home  >  Article  >  Database  >  sql遍历字符串语句

sql遍历字符串语句

WBOY
WBOYOriginal
2016-06-07 17:49:151950browse

sql遍历字符串实现有需要的朋友可参考参考。

 代码如下 复制代码

declare @ddd   varchar(50),@split varchar(1)

set @ddd = '12345678,1234567890,1234567890,123456,123456789'

set @split = ','
while(charindex(@split,@ddd)0)
begin
    select substring(@ddd,1,charindex(@split,@ddd)-1)
    set @ddd = stuff(@ddd,1,charindex(@split,@ddd),'')
    select @ddd
end

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn