2011-07-22 136 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