1

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 RowNumber > (@PageNumber - 1) * @ProductsPerPage
AND RowNumber <= @PageNumber * @ProductsPerPage

I got this error

**Incorrect syntax near ')'.**

Can anyone solve it for me? Thanks in advance

1 Answer 1

11

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

Sign up to request clarification or add additional context in comments.

1 Comment

Nice! I'll add that the original poster should be able to double-click directly on the error and it should take you very close to where the problem is. Should make future typos easier to find... :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.