Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 stored procedure with multple out parameters

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2006-07-14 : 08:55:49
Noémio writes "hi! i would like to know how to write a stored procedure wtih multiple in and out parameters. thanx"

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2006-07-14 : 09:01:45
You can define as many in & out parameters as u want, only you have to suffix output parameters with keyword OUTPUT.

here is an example from BOL:

CREATE PROCEDURE get_sales_for_title
@title varchar(80), -- This is the input parameter.
@ytd_sales int OUTPUT -- This is the output parameter.
AS

-- Get the sales for the specified title and
-- assign it to the output parameter.
SELECT @ytd_sales = ytd_sales
FROM titles
WHERE title = @title

RETURN
GO


Harsh Athalye
India.
"Nothing is Impossible"
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-07-14 : 09:28:46
Call the stored procedure described below with
declare @a int,
@p int

exec uspRectangleCalculations 5, 10, @a out, @p out

select @a Area, @p Perimiter
This is the stored procedure
CREATE PROCEDURE uspRectangleCalculations
(
@Width INT,
@Height INT,
@Area INT OUTPUT,
@Perimiter INT OUTPUT
)
AS

SELECT @Area = @Width * @Height,
@Perimiter = 2 * @Width + 2 * @Height

Peter Larsson
Helsingborg, Sweden
Go to Top of Page
   

- Advertisement -