title: Cast a "-" after a varchar string and then left join another table, sql
body: <p>I am currently working in SQL Server Visual Management Studio 2012. I have 2 tables. <code>Table1</code> has 2 columns; <code>PartNumber as varchar</code>, and <code>dateordered as smalldatetime</code>. <code>Table2</code> has 2 columns, <code>PartNumber as varchar</code>, and <code>time as float</code>. The part numbers on <code>table1</code> are 9 digits long and looks like this <code>'999999999.'</code> The <code>table2</code> part numbers have an extra <code>"-"</code> at the end and will look something like this <code>'999999999-.'</code> I need to add the <code>"-"</code> to the end of the part number on <code>table1</code> and then cross reference that number to table2 and get the time column.</p>
  
  <pre><code>SELECT Right('9', cast(varchar, PartNumber)) as PartNumber 
  from table1  
    Left Join table2 on table1.partnumber = table2.partnumber 
  where DateOrdered BETWEEN ('2015-01-01 00:00:00.000') AND ('2015-05-11 00:00:00.000') 
    AND PartNumber IS NOT NULL
  </code></pre>
  
  <p>-----------------UPDATE
  New code-----------</p>
  
  <pre><code>select table1.partnumber, table2.time from table1 left join table2 on
  table2 + '-' = table1.partnumber
  where DateOrdered IS NOT NULL
  </code></pre>