Matt writes "I recently asked about parsing strings in a stored proc. The article you pointed me to was more than helpful. I have taken it the extra step and added paging. I also have a category specific search included. I just thought I would share. Also, if you see any performance issues, I would be interested in knowing.CREATE PROCEDURE get_SearchPaging ( @array varchar(1000), --search_by @separator char(1), @page int, --page number @recsPerPage int, --records per page @search_in int --category to search in ) ASset nocount ondeclare @separator_position intdeclare @array_value varchar(1000)declare @like_text varchar(1000)Create table #SearchResults (prod_id int)set @array=@array + @separatorWhile patindex('%' + @separator + '%' , @array) <> 0begin select @separator_position = patindex('%' + @separator + '%' , @array) select @array_value = left(@array, @separator_position-1) select @like_text = '%' + @array_value + '%' if @search_in=1000 --if search_in=all categories begin insert into #SearchResults select prod_id from products where prod_num like @like_text insert into #SearchResults select prod_id from products where prod_name like @like_text insert into #SearchResults select prod_id from products where prod_short_desc like @like_text end else --otherwise search in the categories that are associated with --the supercategory begin insert into #SearchResults select a.prod_id from products a, productsXgroup b, groupXsupergroup c where a.prod_num like @like_text and c.supergroup_id=@search_in and c.group_id=b.group_id and b.prod_id=a.prod_id insert into #SearchResults select a.prod_id from products a, productsXgroup b, groupXsupergroup c where a.prod_name like @like_text and c.supergroup_id=@search_in and c.group_id=b.group_id and b.prod_id=a.prod_id insert into #SearchResults select a.prod_id from products a, productsXgroup b, groupXsupergroup c where a.prod_short_desc like @like_text and c.supergroup_id=@search_in and c.group_id=b.group_id and b.prod_id=a.prod_id end select @array=stuff(@array,1,@separator_position, '')end--create a table to rank the records added to #searchResultsCreate table #Rank (temp_id int IDENTITY,prod_id int, Rank int)Insert into #Rankselect prod_id, rank=count(*)from #SearchResultsgroup by prod_idorder by 2 desc--get my first and last record for each pageDeclare @FirstRec int, @LastRec int select @FirstRec=(@page - 1) * @RecsPerPage select @LastRec=(@page * @RecsPerPage + 1) --select out records per page starting with best rankselect a.prod_id, b.prod_num, b.prod_name, b.prod_short_desc, b.prod_mixName,totalRecords=(select count(*) from #SearchResults) , c.rankfrom #SearchResults a, vProducts b, #Rank cwhere c.temp_id>@firstRec and c.temp_id<@lastRec and a.prod_id=b.prod_id and a.prod_id=c.prod_idgroup by a.prod_id, b.prod_num, b.prod_name, b.prod_short_desc, b.prod_mixName, c.rankorder by 7 descset nocount offSincerely,Matt Monahan"