I am receiving the above error when using the below query
SELECT b.*,E.SSNO
FROM [SRV-RVS].[dbo].[CARD] b
INNER JOIN [SRV-RVS].dbo.EMP e
on b.EMPID=E.SSNO
WHERE E.SSNO LIKE 't%'
I am trying to join both tables, here my EMPID is same as SSNO but it got a character in the begining .
Hope you got it
Regards
You could convert EMPID
to a varchar
and add a 'T'
character in the join clause.
SELECT b.*,E.SNO
FROM [SRV-RVS].[dbo].[CARD] b INNER JOIN [SRV-RVS].dbo.EMP e ON ('T' + REPLACE(STR(CAST(b.EMPID as varchar(9)), 9), SPACE(1), '0')) = E.SSNO
WHERE E.SNO LIKE 't%'
Additional notes
-
in your SSNO
column this code will not work.Again (continue from last bullet), change the schema or add a computed column. This is currently a poor design.