declare @i_Prefix as varchar(200)
set @i_Prefix = ''
declare @i_FirstName as varchar(200)
set @i_FirstName = ''
declare @i_MiddleName as varchar(200)
set @i_MiddleName = ''
declare @i_LastName as varchar(200)
set @i_LastName = ''
declare @i_Suffix as varchar(200)
set @i_Suffix = ''
declare @i_NickName as varchar(200)
set @i_NickName = ''
SELECT
TP.FirstName
, TP.LastName
, TA.Address1
, TA.City
, TA.StateProvince
FROM
T_Person TP
, T_Address TA
, T_XREFPersonAddress TXRPa
inner join T_Address on T_Address.ID = T_XREFPersonAddress.IDAddress
left outer join T_XREFPersonAddress on T_XREFPersonAddress.IDPerson = T_Person.IDPerson
Where (lower(TP.Prefix) like (lower(@i_Prefix) + '%') OR TP.Prefix is null)
and (lower(TP.firstname) like (lower(@i_FirstName) + '%') OR TP.firstname is null)
and (lower(TP.middlename) like (lower(@i_MiddleName) + '%') OR TP.middlename is null)
and (lower(TP.lastname) like (lower(@i_LastName) + '%') OR TP.lastname is null)
and (lower(TP.Suffix) like (lower(@i_Suffix) + '%') OR TP.Suffix is null)
and (lower(TP.NickName) like (lower(@i_NickName) + '%') OR TP.NickName is null)
--and TA.ID = TXRPa.IDAddress
--and TP.IDPerson = TXRPa.IDPerson
|