create procedure sp_test
(
@p1 int,
@p2 int,
@p3 int output
)
as.....
go
--调用
declare @iReturn int
declare @V1 int, @V2 int, @V3 intexec @iReturn = sp_test @V1,@V2,@V3 outputselect @iReturn as 返回值,@V3 as 输出参数
(
@p1 int,
@p2 int,
@p3 int output
)
as.....
go
--调用
declare @iReturn int
declare @V1 int, @V2 int, @V3 intexec @iReturn = sp_test @V1,@V2,@V3 outputselect @iReturn as 返回值,@V3 as 输出参数
GO
IF EXISTS(SELECT name FROM sysobjects
WHERE name = 'titles_sum' AND type = 'P')
DROP PROCEDURE titles_sum
GO
USE pubs
GO
CREATE PROCEDURE titles_sum @@TITLE varchar(40) = '%', @@SUM money OUTPUT
AS
SELECT 'Title Name' = title
FROM titles
WHERE title LIKE @@TITLE
SELECT @@SUM = SUM(price)
FROM titles
WHERE title LIKE @@TITLE
GO---调用
DECLARE @@TOTALCOST money
EXECUTE titles_sum 'The%', @@TOTALCOST OUTPUT
IF @@TOTALCOST < 200
BEGIN
PRINT ' '
PRINT 'All of these titles can be purchased for less than $200.'
END
ELSE
SELECT 'The total cost of these titles is $'
+ RTRIM(CAST(@@TOTALCOST AS varchar(20)))