I am trying to join tables. The joining column is a contract number. The table I am trying to join it to has multiple contract numbers, each seperated by commas (ie. Contract1,Contract2,Contract3
).
I have tried using a LEFT CHARINDEX
, and a SUBSTRING CHARINDEX
, but none are working.
The join I have tried doesn't seem to work:
SELECT *
FROM tblA AS C WITH (NOLOCK)
INNER JOIN tblB AS tmp WITH(NOLOCK)
ON CONVERT(VARCHAR, c.Contract_No) =
CONVERT(VARCHAR, LEFT(tmp.ContractNo, CHARINDEX('-', tmp.ContractNo) - 1))