title: how to remove duplicates from a comma seperated string in sql server
body: <p>how to  remove duplicate values from the comma seperated string in sql server. Without using functions</p>
  
  <pre><code> Declare @data varchar(max) = '34.22,768.55,34.22,123.34,12,999.0,999.0'
  </code></pre>
  
  <p>My expected result should be</p>
  
  <pre><code>34.22,768.55,123.34,12,999.0
  </code></pre>
  
  <p>i tried this query but it doesn't remove duplicates from the variable.</p>
  
  <pre><code>Declare @data varchar(max) = '34.22,768.55,34.22,123.34,12,999.0,999.0'
  set @data= (select '' + cast(cast('&lt;d&gt;'+replace(@data, ', ',',&lt;/d&gt;&lt;d&gt;')+'&lt;/d&gt;'  as xml).query('distinct-values(/d)') as varchar(max)) +'')
  </code></pre>