title: SQL Like/Contains on BIGINT Column
body: <p>I have a BIGINT column that I want to do a partial match on.</p>
  
  <p>e.g. <code>@search = 1</code> should return all records where the first number is 1 (1, 11, 100 etc). Basically the same as a varchar LIKE.</p>
  
  <p>I have tried:</p>
  
  <pre><code>DECLARE @search VARCHAR
  SET @search = '1'
  </code></pre>
  
  <p>and</p>
  
  <pre><code>SET @search = '1%'
  </code></pre>
  
  <p>And used:</p>
  
  <pre><code>SELECT
      id FROM table
  WHERE
      CAST(id AS varchar) LIKE @search
  </code></pre>
  
  <p>Adding a <code>%</code> to <code>@search</code> doesn't help. Any ideas how to accomplish this?</p>
  
  <p>EDIT: it seems to be the variable. If I hard code the string in the <code>WHERE</code> clause I get the results I am looking for.</p>
  
  <pre><code>SELECT id FROM table WHERE CAST(id AS VARCHAR) LIKE '14%'
  </code></pre>
  
  <p>This gives me all records with an <code>id</code> of 14* (14, 140, 1400 etc).</p>