I am getting an error in SQL Server for the code.
PDetails ON HEADER.PONUMBER = PDetails.PoNumber
FAN_P ON PDetails.PurchaseOrderID = FAN_P.PurchaseOrderID
Conversion failed when converting the varchar value 'PO321211' to data type int.
The error is clear. You are trying to compare and
INT column to a
VARCHAR column. To alleviate this, you can cast or convert your comparisons to varchar. I did them all since I don't know which is causing the error... but it's the column with
PO321211 in it :)
SELECT DISTINCT HEADER.PONUMBER, SName, CompanyName FROM HEADER INNER JOIN PDetails ON CAST(HEADER.PONUMBER AS VARCHAR(128)) = CAST(PDetails.PoNumber AS VARCHAR(128)) INNER JOIN FAN_P ON CAST(PDetails.PurchaseOrderID AS VARCHAR(128)) = CAST(FAN_P.PurchaseOrderID AS VARCHAR(128))