由于清明小长假缘故,中途几天博客呆滞,下面主要记录了存储过程实现简单的增删改操作:
添加产品类型:
-- ============================================= -- Author: <Author,,Name> -- Create date: <Create Date,,> -- Description: <添加产品类型> -- ============================================= CREATE PROCEDURE productTypeAdd ( @Name nvarchar(50) ) AS BEGIN INSERT [dbo].[productType] ( Name ) VALUES ( @Name ) END GO
修改产品类型:
-- ============================================= -- Author: <Author,,Name> -- Create date: <Create Date,,> -- Description: <修改产品信息> -- ============================================= CREATE PROCEDURE productTypeUpdate ( @id bigint, @name nvarchar(50), ) AS BEGIN update [dbo].[productType] set name=@name, where id=@id END GO
删除产品类型:
-- ============================================= -- Author: <Author,,Name> -- Create date: <Create Date,,> -- Description: <删除产品类型> -- ============================================= CREATE PROCEDURE productTypeDel (@ID BIGINT) AS BEGIN delete from [dbo].[productType] where id=@ID; END GO
查询所有产品信息:
-- ============================================= -- Author: <Author,,Name> -- Create date: <Create Date,,> -- Description: <查询所有产品信息> -- ============================================= CREATE PROCEDURE QueryAllProduct AS BEGIN SELECT a.id,a.Name,a.Price,a.address,a.type,b.id,b.name FROM [dbo].[product] a inner join [dbo].[productType] b on a.type=b.id END GO
添加产品信息
-- ============================================= -- Author: <Author,,Name> -- Create date: <Create Date,,> -- Description: <添加产品信息> -- ============================================= CREATE PROCEDURE productAdd ( @Name nvarchar(50), @Price money, @Address nvarchar(50), @Type int ) AS BEGIN insert [dbo].[product] ( Name, Price, Address, Type ) values ( @Name, @Price, @Address, @Type ) END GO
删除产品信息
-- ============================================= -- Author: <wangzhijun> -- Create date: <Create Date,,> -- Description: <删除产品信息> -- ============================================= CREATE PROCEDURE productDel @ID BIGINT AS BEGIN delete [dbo].[product] where id=@id END GO
原文:http://www.cnblogs.com/tuqun/p/3652833.html