I got this error when trying run my sql query...
Conversion failed when converting the varchar value 'Id' to data type int
SELECT *
FROM History
INNER JOIN Header
ON History.Id = Header.docId
Please help me :(
In your Join condition am sure one column is of Integer type and other one is Varchar type.
ON History.Id = Header.docId
since Int has higher precedence than varchar, Varchar column will be implicitly converted to Int
So explicitly convert the Int column to varchar.
ON History.Id = cast(Header.docId as varchar(50))
I have considered Header.docId as Int type if no, then convert History.Id to varchar
Try casting Id column to INT
SELECT *
FROM History
INNER JOIN Header
ON cast(History.Id AS int) = Header.docId
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With