日期:2014-05-17 浏览次数:20659 次
CREATE PROCEDURE CatalogGetOriductsOnFrontPromo
(@DescriptionLength INT
@PageNumber INT,
@ProductsPerPAge INT,
@HowManyProducts INT OUTPUT
)
AS
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,
Status binary(50)
}
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,Status
Fromo Product
Where PrmoFront=1
Select @HowManyProducts=Count(ProductID) From @Products
Select ProductID, Name,Description,Price,Thumbnail,Image,PromoFront,PromoDept
Status
FROM @Products
WHere RowNumber>(@PageNumber-1)*@ProductsPerPage And
RowNumber<=@PageNumber*@PrductsPerPage