DECLARE @valueList varchar(8000)
DECLARE @pos INT
DECLARE @len INT
DECLARE @value varchar(8000)
SET @valueList = '00000129563698'
set @pos = 0
set @len = 0
WHILE CHARINDEX('0', @valueList, @pos+1)<>0
BEGIN
set @len = CHARINDEX('0', @valueList, @pos+1) - @pos
set @value = SUBSTRING(@valueList, @pos, @len)
PRINT @value
set @pos = CHARINDEX('0', @valueList, @pos+@len) +1
END
我想从@valueList
变量中删除零并将剩余部分存储在另一个变量中。
我怎样才能在sql中做到这一点?