I am trying to use the "Paging through Records using a Stored Procedure" method for a search engine (Article http://www.4guysfromrolla.com/webtech/113000-1.3.shtml ). I can&#039;t figure out how to pass in the the where clause ... here is the code I am trying to use in the stored procedure...<BR><BR>CREATE PROCEDURE sp_PagedResults<BR> (<BR> @Page int,<BR> @RecsPerPage int,<BR> @WhereClause nvarchar(255)<BR> )<BR>AS<BR><BR>-- We don&#039;t want to return the # of rows inserted<BR>-- into our temporary table, so turn NOCOUNT ON<BR>SET NOCOUNT ON<BR><BR>-- Find out where we will start our records from<BR>DECLARE @RecCount int<BR><BR>SELECT @RecCount = @RecsPerPage * @Page + 1<BR><BR><BR>--Create a temporary table<BR>CREATE TABLE #TempItems<BR>(<BR> ID int IDENTITY,<BR> CatID int NOT NULL,<BR> LinkName nvarchar(50) NULL,<BR> LinkAdded datetime NULL,<BR> LinkURL nvarchar(100) NULL,<BR> LinkDesc ntext NULL,<BR> LinkHits smallint NOT NULL<BR>)<BR><BR>-- Insert the rows from links into the temp. table<BR>INSERT INTO #TempItems (CatID, LinkName, LinkAdded, LinkURL, LinkDesc, LinkHits)<BR>SELECT CatID,LinkName,LinkAdded,LinkURL,LinkDesc,LinkHits FROM links WHERE @WhereClause<BR><BR>-- Find out the first and last record we want<BR>DECLARE @FirstRec int, @LastRec int<BR>SELECT @FirstRec = (@Page - 1) * @RecsPerPage<BR>SELECT @LastRec = (@Page * @RecsPerPage + 1)<BR><BR>-- Now, return the set of paged records, plus, an indiciation of we<BR>-- have more records or not!<BR>SELECT *,<BR> MoreRecords = <BR> (<BR> SELECT COUNT(*) <BR> FROM #TempItems TI<BR> WHERE TI.ID &#062; @LastRec<BR> ) <BR>FROM #TempItems<BR>WHERE ID &#062; @FirstRec AND ID &#060; @LastRec<BR><BR><BR>-- Turn NOCOUNT back OFF<BR>SET NOCOUNT OFF<BR><BR><BR>The problem is if I use @WhereClause after the WHERE, the procedure won&#039;t pass a syntax check. If I use an actual value for WHERE (for example, ApprovalURL = &#039;1&#039;) the procedure will compile and work fine...but I want to limit the records copied into the temp table to the @WhereClause selection criteria that is being passed in. If the 4GuysFromRolla would post thier sp_PagedResults procedure it would help me greatly.<BR>