title: comma separated values (CSV) to an array
body: <pre><code>declare @inputString nvarchar(20) = 'a,bc,def,ghij'
  declare @i int = 1
  declare @j int = 0
  declare @character nvarchar(1) 
  while(@i &lt;= LEN(@inputString))
  begin
  set @character =  SUBSTRING(@inputstring,@i,1)
  if (@character = ',')
  begin
  substring(@inputstring,@i,1)=' ' --it is showing an error near substring here
  end
  set @i = @i + 1
  end
  </code></pre>
  
  <p>Kindly help me rectify this error , can't we use <code>substring</code> on the left hand side of the expression?</p>
  
  <p>I am trying to get all the commas and replace them with a space. Also, how can I convert the space separates values to an array?</p>