SQL Server is behoorlijk intelligent als het gaat om het vergelijken van waarden met verschillende datatypes.
Het volgende script werkt zoals het is zonder enige expliciete conversie
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
Resultaat
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