开发者

SQL Server stored procedure error

I am inserting stored procedure and the code is

CREATE PROCEDURE CatalogGetProductsOnFrontPromo (@DescriptionLength INT, @PageNumber INT,
                                                @ProductsPerPage INT, @HowManyProducts INT OUTPUT)
AS
-- declare a new TABLE variable
DECLARE @Products TABLE (RowNumber INT, ProductID INT, Name NVARCHAR(50), Description NVARCHAR(MAX),
            Price MONEY, Thumbnail NVARCHAR(50), Image NVARCHAR(50), PromoFront bit, PromoDept bit)
-- populate the table variable with the complete list of products
INSERT INTO @Products
SELECT ROW NUMBER() OVER (ORDER BY Product.ProductID), ProductID, Name,
CASE WHEN LEN(Description) <= @DescriptionLength THEN Description
ELSE SUBSTRING(Description, 1, @DescriptionLength) + '...' END
AS 
Description, Price, Thumbnail, Image, PromoFront, PromoDept
FROM Product
WHERE PromoFront = 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, Thumbnail, Image, PromoFront, PromoDept
FROM @Products
WHERE RowNu开发者_JAVA技巧mber > (@PageNumber - 1) * @ProductsPerPage
AND RowNumber <= @PageNumber * @ProductsPerPage

I got this error

**Incorrect syntax near ')'.**

Can anyone solve it for me? Thanks in advance


ROW_NUMBER() instead of ROW NUMBER() (have a look at underscore)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜