title: String Comparison differences between .NET and T-SQL?
body: <p>In a test case I've written, the string comparison doesn't appear to work the same way between SQL server / .NET CLR.</p>
  
  <p>This C# code:</p>
  
  <pre><code>string lesser =  "SR2-A1-10-90";
  string greater = "SR2-A1-100-10";
  
  Debug.WriteLine(string.Compare("A","B"));
  Debug.WriteLine(string.Compare(lesser, greater));
  </code></pre>
  
  <p>Will output:</p>
  
  <pre><code>-1
  1
  </code></pre>
  
  <p>This SQL Server code:</p>
  
  <pre><code>declare @lesser varchar(20);
  declare @greater varchar(20);
  
  set @lesser =  'SR2-A1-10-90';
  set @greater = 'SR2-A1-100-10';
  
  IF @lesser &lt; @greater
      SELECT 'Less Than';
  ELSE
      SELECT 'Greater than';
  </code></pre>
  
  <p>Will output:</p>
  
  <pre><code>Less Than
  </code></pre>
  
  <p>Why the difference?</p>