Looks like you can only select one type so no need for that csv list.Send null if all services are selectedcreate proc s_search@postcode varchar(100) ,@Type int ,@Keywords varchar(1000)as set nocount on create table @BusIds(id int) create table @KeywordTbl(s varchar(50)) insert @ActTypes select * from dbo.fn_ParseCSVString(@csvAccountntType, ',') insert @KeywordTbl select * from dbo.fn_ParseCSVString(@Keywords, ' ') -- get the id's of the accountants - might be more flexible insert @BusIds select distinct b.business_id from BUSINESS b join ACCOUNTANT_BUSINESS ab on ab.business_id = b.business_id join BUSINESS_DETAILS bd on b.business_id = bd.business_id join @KeywordTbl kt on ' ' + kt.s + ' ' like '% ' + business_description + ' %' where (b.PostCode = @postcode or b.Suburb = @postcode) and (ab.type_id = @AccountType or @Type is null) select * from BUSINESS_DETAILS bd join @BusIds bids on bd.business_id = bids.idgo
==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy.