Something like this should be very close at least, I think:
create proc pSearch
@searchparam varchar(400) -- values will be entered like this - seperated by comma: John, Mary, 23.10.1980
as
set @searchparam = @searchparam + ','
declare @value varchar(100)
set @value = ''
-- create temp table to enter search values separated in rows
create table #search(value varchar(100) primary key)
-- insert each unique value into #search
while charindex(',',@searchparam)> 0
begin
set @value = left(@searchparam, charindex(',',@searchparam)-1)
set @searchparam = ltrim(right(@searchparam,len(@searchparam) - charindex(',',@searchparam)))
insert into #search select @value where not exists ( select 1 from #search where value = @value )
end
UPDATE STATISTICS #search WITH FULLSCAN
-- return all clients which match any one of the search criteria with like operator
select distinct c.id, c.firstname, c.lastname, c.birthdate
from dbo.tblclient c
inner join #search s on
c.Firstname like s.value
or c.Lastname like s.value
or c.birthdate like s.value
go
SQL DBA,SQL Server MVP(07, 08, 09) A socialist is someone who will give you the shirt off *someone else's* back.