In my opinion the error ocurrs because there are records in the farmerregistration table that conteins 'no number' in the farmerid field (for example: A12334, 213 F... or something like this).
So, the
where a.transactionid = b.farmerid
treats to convert this 'no numbers' values to a bigint and causes an error.
Try to use:
where ltrim(rtrim(a.transactionid))=ltrim(rtrim(convert( varchar(50), b.farmerid)))
(Explanation, instead of implicit convert varchar to bigint, convert explicitly bigint to varchar and then compare the alltrim [ltrim, rtrim] of that values)