有没有什么简单的方法,可以分解一个字符串的。分解规则,字母,汉字,数字等可以分开   例如'string023汗a'   就分给4个变量 @a = 'string'  @b = '023' @c = '汗' @d = 'a'
       求一个简单高效的方法     ^_^

解决方案 »

  1.   

    declare @str nvarchar(100)
    set @str=N'string023汗a我1H你8' 
    declare @no int
    set @no=1
    declare @char char(1)
    declare @if int
    declare @output varchar(100)
    while @no<=LEN(@str)
    begin 
    set @if =@no
    set @char= SUBSTRING(@str,@no,1)
    while @char like '[a-z]'
    begin 
    set @no=@no+1
    select @char= SUBSTRING(@str,@no,1)
    end 
    if @if<>@no
    begin
    select SUBSTRING(@str,@if,@no-@if)
    set @if =@no
    end 
    while (ISNUMERIC(@char)>0)
    begin 
    set @no=@no+1
    select @char= SUBSTRING(@str,@no,1)
    end 
    if @if<>@no
    begin 
    select SUBSTRING(@str,@if,@no-@if)
    set @if =@no
    end 
    while((ISNUMERIC(@char)<=0 )and(@char like '[^a-z]') and @no<=LEN(@str))
    begin 
    set @no=@no+1
    select @char= SUBSTRING(@str,@no,1)
    end 
    if @if<>@no
    begin
    select SUBSTRING(@str,@if,@no-@if)
    set @if =@no
    end
    end 可以分开数字、字母和汉字