Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Problems with SQL server 2000 paging

Author  Topic 

tbathgate
Starting Member

2 Posts

Posted - 2006-11-30 : 14:51:46
HI all,

I am very new to SQL server and have been working my way through a book to learn ASP.Net v2 and SQL by building a e-commerce site.

There are 3 stored procedures which are used to implement paging from retrieving products from the catalog, which are either on a catalog promotion or a department promotion.

The problem is is that the stored procedure is written in sql 2005 and doesn't work on sql 2000.

I have been trying to change this to sql 2000 but don't have enough experience of sql to do this. can anyone help me with this.

If someone can help me with one of the procedures then i think i should be able to fix the other two.

One of the procedures look like this:

CREATE PROCEDURE GetProductsOnCatalogPromotion
(@DescriptionLength INT,
@PageNumber INT,
@ProductsPerPage INT,
@HowManyProducts INT OUTPUT)
AS

-- declare a new TABLE variable
DECLARE @Products TABLE
(RowNumber INT,
ProductID INT,
Name VARCHAR(50),
Description VARCHAR(5000),
Price MONEY,
Image1FileName VARCHAR(50),
Image2FileName VARCHAR(50),
OnDepartmentPromotion BIT,
OnCatalogPromotion BIT)

-- populate the table variable with the complete list of products
INSERT INTO @Products
SELECT ROW_NUMBER() OVER (ORDER BY Product.ProductID),
ProductID, Name,
SUBSTRING(Description, 1, @DescriptionLength) + '...' AS Description,
Price, Image1FileName, Image2FileName, OnDepartmentPromotion, OnCatalogPromotion
FROM Product
WHERE OnCatalogPromotion = 1

-- return the total number of products using an OUTPUT variable
SELECT @HowManyProducts = COUNT(ProductID) FROM @Products

-- extract the requested page of products
SELECT ProductID, Name, Description, Price, Image1FileName,
Image2FileName, OnDepartmentPromotion, OnCatalogPromotion
FROM @Products
WHERE RowNumber > (@PageNumber - 1) * @ProductsPerPage
AND RowNumber <= @PageNumber * @ProductsPerPage


I would really appreciate anybodies help that can help me with this. i have really tried but i can't get this right

Thanks in advance

DustinMichaels
Constraint Violating Yak Guru

464 Posts

Posted - 2006-11-30 : 15:00:16
I don't think the ROW_NUMBER() function is supported in SQL server 2005.

You will need to implement paging another way. If you try to search the forums I'm sure you will find one that will work in SQL server 2000.

Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2006-11-30 : 15:08:36
"If you try to search the forums ..."

e.g.

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=55210&SearchTerms=Efficient+paging+of+recordsets

Kristen
Go to Top of Page

tbathgate
Starting Member

2 Posts

Posted - 2006-11-30 : 15:52:37
I tried search the forum but the problem is that i dont understand enough about sql to use these solutions.

I vaguley understand this code and the code that accesses the catalog relies on this procedure which i am not confident enough to re-write.

Can anybody even point me in this code what needs changed. I am aware the ROW_NUMBER doesn't work in SQL 2000, but I don't understant the whole identity field and temporary tables.

I read the blog on efficient paging, but I don't really know how to implement this.

Any help or suggestion are much appreciated!

Tom
Go to Top of Page
   

- Advertisement -