CREATE PROCEDURE GetProductByCategory
(
@categoryId int,
@pageSize int,
@pageIndex int
)
AS
DECLARE @sql nvarchar(4000)
SET @sql = select top +cast(@pagesize as varchar(20))+ * from ProductInfo
where CategoryId= +cast(@categoryId as varchar(20))+
and ProductInfo.ProductId not in (select top +cast((@pageSize*@pageindex) as varchar(20))
+ ProductID from ProductInfo where CategoryId =
+cast(@categoryId as varchar(20))+order by productId) order by productId
EXEC sp_ExecuteSql @sql
GO
EXEC sp_ExecuteSql @sql是什么用的?
这个简单呀