Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Efficient Paging Pain
Message
De
11/07/2007 15:45:06
 
 
À
Tous
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Titre:
Efficient Paging Pain
Versions des environnements
SQL Server:
SQL Server 2005
Divers
Thread ID:
01239477
Message ID:
01239477
Vues:
70
I am trying to develop a stored proc which will return a set of records for a given keyword based upon the fulltext index. The trick here is that the table store records from various clients. Client 0 is a vast (6,000,000) repository of nearly all references, whereas the individual clients are preferred. Here is code which does not work. Please help.
USE [AWS2]
GO
/****** Object:  StoredProcedure [dbo].[TestGetinvByPage]    Script Date: 07/11/2007 14:27:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROC [dbo].[TestGetinvByPage]
(@PageSize int = 10 , @PageNumber int = 2, @kw Varchar (40) = 'pencil', @clientid int = 2)

AS 

Declare @RowStart int 
Declare @RowEnd int 

if @PageNumber > 0 
Begin 

SET @PageNumber = @PageNumber -1 

SET @RowStart = @PageSize * @PageNumber + 1; 
SET @RowEnd = @RowStart + @PageSize - 1 ;

with InvRows as 
(	 select uid,isbn13,description from inv 
		where uidclient = @clientid and 
			contains("description",@kw) 
union
	 select uid,isbn13,description from inv 
		where uidclient = 0 and 
			contains("description",@kw) 

)


With InvRecs AS 
     ( SELECT uidclient, uid, description, 
       ROW_NUMBER() OVER (order by uid) as RowNumber 
       FROM  Invrows )

select * 
from Invrecs
Where RowNumber >= @RowStart and RowNumber <= @RowEnd 

END
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform