谢了

解决方案 »

  1.   


    DECLARE @count INT
    DECLARE @cursor INT
    DECLARE @string NVARCHAR(2000)
    DECLARE @char NVARCHAR(1)
    SET @count = 0
    SET @cursor = 0
    SET @string = ',,,as,asd,asdf,assss,wewe.,asd,,,,'
    SET @char = ','
    WHILE (CHARINDEX(@char,@string)>0)
    BEGIN Set @cursor = CHARINDEX(@char,@string)
    SET @string = SUBSTRING(@string,@cursor+1,LEN(@string)-@cursor);
    SET @count = @count+1;
    END
    PRINT @count
      

  2.   


    declare @s varchar(200)
    set @s='sa,asdf,asdf,asdf'
    select len(@s)-len(replace(@s,',',''))/*
                
    ----------- 
    3(所影响的行数为 1 行)*/