I got this error when trying run my sql query...
Conversion failed when converting the varchar value \'Id\' to data type int
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