SQL joining two tables with a large id number

I have two tables that look like this:

Value   EntryID
0200    43300008191907010611241000917561326051

Value   EntryID
test    43300008191907010611241000917561326051

I want to join them through an INNER JOIN at EntryID, but even if it is nvarchar, the connection does not work (I get nothing as a result, my new table is empty). Why?

SELECT * FROM #T_TableA AS A INNER JOIN #T_TableB AS B ON A.EntryID = B.EntryID
+4
source share
2 answers

Maybe one field contains extra spaces? Use the function TRIMto remove spaces:

It should look like this:

INNER JOIN #T_TableB AS B ON TRIM(A.EntryID) =TRIM(B.EntryID) 

Or:

INNER JOIN #T_TableB AS B ON RTRIM(LTRIM(A.EntryID)) =RTRIM(LTRIM(B.EntryID))
-1
source

. . , . , , UNION

-3

All Articles