title: trim sql variant
body: <p>I have column sql variant, which has the following meanings: <code>100, 150, D1</code>
  I'm trying to convert all numbers in the columns into letters (such as <code>D1</code>) according to specific logic in case when. But <code>150</code> has spaces and the <code>CASE WHEN</code> doesn't work. </p>
  
  <p>Here's the query I'm using:</p>
  
  <pre><code>Select  *,
          Case When LTrim(Cast(AttributeValue As NVarchar(Max))) Between 0 And 200 Then 'D1'
               Else 'Other'
          End
  From    MyTable As SCR With (NoLock); 
  </code></pre>
  
  <p>I tried the following</p>
  
  <pre><code>LTRIM(CAST column AS VARCHAR(MAX))
  </code></pre>
  
  <p>but now I get error:</p>
  
  <blockquote>
    <p>Conversion failed when converting the nvarchar value 'D1' to data type int</p>
  </blockquote>
  
  <p>How can I remove spaces from sql_variant?</p>