SQL Server er ret intelligent, når det kommer til at sammenligne værdier med forskellige datatyper.
Følgende script fungerer som det er uden nogen eksplicit konvertering
DECLARE @TableA TABLE (VARCHARID VARCHAR(48) PRIMARY KEY)
DECLARE @TableB TABLE (GUIDID UNIQUEIDENTIFIER PRIMARY KEY)
INSERT INTO @TableA VALUES
('{0CAF3FBC-3C76-420B-B0C4-42867551E3B5}')
, ('{0CAF3FBC-3C76-420B-B0C4-42867551E3B6}')
, ( '0CAF3FBC-3C76-420B-B0C4-42867551E3B7' )
, ( '0CAF3FBC-3C76-420B-B0C4-42867551E3B8' )
INSERT INTO @TableB VALUES
('{0CAF3FBC-3C76-420B-B0C4-42867551E3B5}')
, ( '0CAF3FBC-3C76-420B-B0C4-42867551E3B6' )
, ('{0CAF3FBC-3C76-420B-B0C4-42867551E3B7}')
, ( '0CAF3FBC-3C76-420B-B0C4-42867551E3B8' )
SELECT *
FROM @TableA a
INNER JOIN @TableB b ON b.GUIDID = a.VARCHARID
Resultat
VARCHARID GUIDID
{0CAF3FBC-3C76-420B-B0C4-42867551E3B5} 0CAF3FBC-3C76-420B-B0C4-42867551E3B5
{0CAF3FBC-3C76-420B-B0C4-42867551E3B6} 0CAF3FBC-3C76-420B-B0C4-42867551E3B6
0CAF3FBC-3C76-420B-B0C4-42867551E3B7 0CAF3FBC-3C76-420B-B0C4-42867551E3B7
0CAF3FBC-3C76-420B-B0C4-42867551E3B8 0CAF3FBC-3C76-420B-B0C4-42867551E3B8