SQLTeam.com | Weblogs | Forums

T-sql 2012 use like statement


In t-sql 2012, I want to compare the values of 2 columns the values of [Identity].MiddleName to ALF.SPA1_MiddleName. The [Identity].MiddleName will always have the correct name but the ALF.SPA1_MiddleName
field will usually only have part of the name. See t-sql below:
select *
from test1.dbo.DianeALFUser ALF
JOIN test2.DBO.[Identity] [Identity] WITH (NOLOCK)
on upper(ALF.SPA1_LastName) = upper([Identity].lastName)
and upper(ALF.SPA1_FirstName) = upper([Identity].firstName)
and (([Identity].MiddleName is NULL and ALF.SPA1_MiddleName is null)
OR ([Identity].MiddleName = ALF.SPA1_MiddleName ))

Thus can you show me how to use a like or wild card compare on the line listed below:
OR ([Identity].MiddleName = ALF.SPA1_MiddleName ))


[Identity].MiddleName LIKE ALF.SPA1_MiddleName + '%'