求一存储过程
嗯,昨天洗澡把头碰坏了,轻微脑震荡,思考不能状态
希望有人帮忙写个过程
要求如下:
入口参数:
1、要查看的页号:
2、每页的纪录数:
3、材料ID:为0表示不指定材料,非0表示指定察看某一特定材料
4、材料代码:模糊匹配
5、所属类别:(注意:需包括其子类别的产品)为0表示所有类别
返回值:
1、取得的产品数
2、返回总页数
库结构如下:
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Tb_Product]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[Tb_Product]
GO
CREATE TABLE [dbo].[Tb_Product] ( -----------------------产品表----
[Id] [int] IDENTITY (1, 1) NOT NULL ,
[ProductCode] [Varchar] (20) NULL ,-- 产品代码
[ParentId] [int] NULL ,-- 产品所属类别
[ProductUnit] [Varchar] (20) NULL ,-- 单位
[ProductDesc] [Varchar] (100) NULL -- 说明
) ON [PRIMARY]
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Tb_ProductClass]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[Tb_ProductClass]
GO
CREATE TABLE [dbo].[Tb_ProductClass] ( -----------------类别表-----
[Id] [int] IDENTITY (1, 1) NOT NULL ,
[ParentID] [int] NUll,--- 类别的父类 1级类别为0
[ProductInfo] [Varchar] (200) NULL, -- 类别说明
[Level] int Null --类别层次
) ON [PRIMARY]
GO