SELECT
mt.##col1##, ..., jt.##co11##, ...
FROM dbo.maintable mt
LEFT OUTER JOIN jointable jt ON
--ignore last two bytes of patid if they are alpha, because it's a state abbrev, not part of key value
jt.key = LEFT(mt.patid, LEN(mt.patid) - CASE WHEN RIGHT(mt.patid, 2) LIKE '[a-z][a-z]' THEN 2 ELSE 0 END)
Edit: Added sql code tags to colorize code.
SQL DBA,SQL Server MVP(07, 08, 09) A socialist is someone who will give you the shirt off *someone else's* back.