首页 > 其他 > 详细

存储过程学习(二)

时间:2014-04-08 22:34:56      阅读:561      评论:0      收藏:0      [点我收藏+]

由于清明小长假缘故,中途几天博客呆滞,下面主要记录了存储过程实现简单的增删改操作:

添加产品类型:

bubuko.com,布布扣
-- =============================================
-- Author:        <Author,,Name>
-- Create date: <Create Date,,>
-- Description:    <添加产品类型>
-- =============================================
CREATE PROCEDURE productTypeAdd
 (
 @Name nvarchar(50)
 )
AS
BEGIN
    INSERT [dbo].[productType]
    (
    Name
    )
    VALUES
    (
    @Name
    )
END
GO
bubuko.com,布布扣

修改产品类型:

bubuko.com,布布扣
-- =============================================
-- 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
bubuko.com,布布扣

删除产品类型:

bubuko.com,布布扣
-- =============================================
-- Author:        <Author,,Name>
-- Create date: <Create Date,,>
-- Description:    <删除产品类型>
-- =============================================
CREATE PROCEDURE  productTypeDel
    (@ID BIGINT)
AS
BEGIN
    delete from [dbo].[productType]
    where  id=@ID;
END
GO
bubuko.com,布布扣

查询所有产品信息:

bubuko.com,布布扣
-- =============================================
-- 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
bubuko.com,布布扣

添加产品信息

bubuko.com,布布扣
-- =============================================
-- 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
bubuko.com,布布扣

删除产品信息

bubuko.com,布布扣
-- =============================================
-- Author:        <wangzhijun>
-- Create date: <Create Date,,>
-- Description:    <删除产品信息>
-- =============================================
CREATE PROCEDURE productDel
@ID BIGINT
AS
BEGIN
    delete [dbo].[product]
    where id=@id
END
GO
bubuko.com,布布扣

 

存储过程学习(二),布布扣,bubuko.com

存储过程学习(二)

原文:http://www.cnblogs.com/tuqun/p/3652833.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!