sql存储过程

时间:2014-01-14 19:32:23   收藏:0   阅读:532

下面是一个最简单的存储过程,传入一个ID,得到这个ID对应的数据。 

bubuko.com,布布扣
CREATE PROCEDURE GetQuestionByNo 
    -- Add the parameters for the stored procedure here
    @shopNo int = 0
AS
BEGIN
    -- SET NOCOUNT ON added to prevent extra result sets from
    -- interfering with SELECT statements.
    SET NOCOUNT ON;

    -- Insert statements for procedure here
    SELECT * from dbo.DQuestionData where shop_no = @shopNo
END
GO
bubuko.com,布布扣

 删除存储过程

drop procedure GetQuestionByNo

 与函数Function的不同,Function的参数要用()号,而存储过程不用,存储过程可以指定缺省值,并且调用的时候可以不指定。

如下面两种都可以

exec GetQuestionByNo 2
exec GetQuestionByNo

原文:http://www.cnblogs.com/xiashengwang/p/3512423.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!