title: Loop through a character in sql
body: <pre><code>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)&lt;&gt;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
  </code></pre>
  
  <p>I want to remove the zeros from <code>@valueList</code> variable and store the remaining part in another variable. </p>
  
  <p>How can I do this in sql?</p>