I have a SQL query that compares a value in the database to a constant:
SELECT * FROM my_table INNER JOIN #TempTable tem ON my_table.id = temp.id AND
Seems your id's are VARCHARs with different collations.
id
VARCHAR
Try this:
SELECT * FROM my_table INNER JOIN #TempTable tem ON my_table.id = temp.id COLLATE SQL_Latin1_General_CP1_CI_AS AND my_table.key = 'SOME STRING'