There is no need to concatenate all of them into a comma delimited string.
IN
accepts a sub query that returns a single column of items to be tested. Just use
SELECT [ITEM_KEY],
max([REVISION]) Rev
INTO #rev
FROM SERVER2.[BOMSystem].[dbo].[ITEM]
WHERE ITEM_KEY COLLATE DATABASE_DEFAULT IN (SELECT LTRIM(ItemNumber )
FROM #ShipTemp)
AND DATE_EFF_FROM <= @shipedon
GROUP BY ITEM_KEY
Also no need to RTRIM
as trailing spaces aren't significant in a comparison and if ItemNumber
is numeric you should use a numeric datatype, not a string.