Hugo Kornelis (12/24/2009)
If you are unsure if the field contains a wildcard character when joining using the LIKE operator, you can avoid false positive results by observing this tip:
But what is the point of using LIKE if you do this? Why not simply use the = operator?
In general, you probably wouldn't use LIKE exactly like that, but with your own wildcards attached. For example, you may want to see if a string contains another string in its entirety. If the second string might have a wildcard in it, you'd have to do something like:
select * from #table1 t1
inner join #table2 t2
on t1.Col1 like
'%' + REPLACE(REPLACE(t2.Col1,'%','[%]'),'_','[_]') + '%'
Otherwise, the wildcard in the second string may cause false positives.