2011-07-22 121 views
1

我插入存储过程的代码是SQL Server存储过程的错误

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 

我得到这个错误

**Incorrect syntax near ')'.** 

谁能解决一下吗?在此先感谢

回答

11

ROW_NUMBER(),而不是ROW NUMBER()(看看下划线)

+0

哇,好点。 – MatBailie

+1

+1 - 好眼睛! – JNK

+0

不错!我会补充说,原始的海报应该能够直接在错误上双击,它应该会让你非常接近问题所在。应该让未来的拼写错误更容易找到...... :) – mwigdahl