title: Search half the refID in SQL
body: <p>I have a SQL table which hold unique REFID (int) and many other columns. I wanted to search a row using the half REFID . So if someone just search <strong>0001</strong> then 50001, 00015... comes up.</p>
  
  <p>I have tried:</p>
  
  <pre><code>SELECT TOP 10 REFID     
  FROM Tablename
  where REFID LIKE '%' + cast(0001 as varchar(10)) +'%'
  </code></pre>
  
  <p>however the problem is, it also giving me 150100 however I wanted <strong>0001</strong> to be in order.</p>
  
  <p><strong>'0001' is passed in as a parameter</strong> passed in from my C# application. I know I can convert the '0001' to string/varchar before sending it to the SQL however I was looking for a way to do it within the SQL so I can pass in the int from C# application</p>