sql 存储过程取值
一般的存储过程取值,有select查询,output输出参数,return返回值,raiserror 值,其中return必有返回值,如不指定return值,将返回0
SET NOCOUNT ON;设定是否返回受影响的行
多语句,取受影响的行数结果不准确
1, select 查询表数据返回
CREATE PROCEDURE [dbo].[GetMaxIssue]
AS
BEGIN
SET NOCOUNT ON;
-- Insert statements for procedure here
SELECT max( issue) as maxissue from b_issuelist
END
2,OUTPUT参数取值
CREATE PROCEDURE [dbo].[GetMaxIssue]
@Maxissue int output
AS
BEGIN
SET NOCOUNT ON;
-- Insert statements for procedure here
SELECT @Maxissue = max( issue) from b_issuelist
END
3,返回值取值
CREATE PROCEDURE [dbo].[GetMaxIssue]
@Maxissue int output
AS
BEGIN
SET NOCOUNT ON;
-- Insert statements for procedure here
SELECT @Maxissue = max( issue) from b_issuelist --OUTPUT 参数
return @maxissue + 1 --返回值
END
还有 raiserror 暂无实例