Will something like this work for you?
select * from [Table A] a join [Table B] b On REPLACE(a.Name, ' ', '') = REPLACE(b.Name, ' ', '')
Use the Replace function to remove all spaces and compare the results.
For exampe, run this
select
CASE
WHEN REPLACE('T E S T', ' ', '') = REPLACE('TE ST', ' ', '') THEN 'TRUE' else 'FALSE'
END
Use code to replace all non-alpha characters:
CREATE FUNCTION [dbo].[fncRemoveNonAlphanumericChars](@Temp VarChar(1000))
RETURNS VarChar(1000)
AS
BEGIN
WHILE PatIndex('%[^A-Za-z0-9]%', @Temp) > 0
SET @Temp = Stuff(@Temp, PatIndex('%[^A-Za-z0-9]%', @Temp), 1, '')
RETURN @TEmp
END
Example:
SELECT dbo.fncRemoveNonAlphanumericChars('abc...DEF,,,GHI(((123)))456jklmn')
Result:
abcDEFGHI123456jklmn
(This was from here: http://jayhollingum.blogspot.com/2011/01/sql-server-remove-non-alphanumeric.html)