DECLARE @SPACE_COUNT INT,
@STRING VARCHAR(2000)
SET @STRING = '中文 输入 234'
SET @SPACE_COUNT = LEN(@STRING) - LEN(REPLACE(@STRING, ' ', ''))
PRINT @SPACE_COUNT
@STRING VARCHAR(2000)
SET @STRING = '中文 输入 234'
SET @SPACE_COUNT = LEN(@STRING) - LEN(REPLACE(@STRING, ' ', ''))
PRINT @SPACE_COUNT
你把所有的都replace了
这样也许好些
declare @int int,@k varchar(20),@len int,@count int
select @k='j j j j'
select @int=0
select @len=len(@k)
select @len
select @count=0
while @int<@len
begin
select @int=charindex(' ',@k,@int)
select @int=@int+1
if @int=0
break
select @count=@count+1
end
select @count