sql server - Cast a "-" after a varchar string and then left join another table, sql -
i working in sql server visual management studio 2012. have 2 tables. table1
has 2 columns; partnumber varchar
, , dateordered smalldatetime
. table2
has 2 columns, partnumber varchar
, , time float
. part numbers on table1
9 digits long , looks '999999999.'
table2
part numbers have "-"
@ end , '999999999-.'
need add "-"
end of part number on table1
, cross reference number table2 , time column.
select right('9', cast(varchar, partnumber)) partnumber table1 left join table2 on table1.partnumber = table2.partnumber dateordered between ('2015-01-01 00:00:00.000') , ('2015-05-11 00:00:00.000') , partnumber not null
-----------------update new code-----------
select table1.partnumber, table2.time table1 left join table2 on table2 + '-' = table1.partnumber dateordered not null
not quite sure question, not working?:
table1.partnumber + '-' = table2.partnumber
(not elegant way of doing things)
Comments
Post a Comment