SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 specifying paramters as both input and output
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

SQLIsTheDevil
Posting Yak Master

USA
177 Posts

Posted - 12/19/2007 :  12:36:07  Show Profile  Reply with Quote
Simple question really: How do I specify a paramter as both input and output in a procedure?

SwePeso
Patron Saint of Lost Yaks

Sweden
30114 Posts

Posted - 12/19/2007 :  12:47:40  Show Profile  Visit SwePeso's Homepage  Reply with Quote
quote:
Originally posted by SQLIsTheDevil

Simple question really: How do I specify a paramter as both input and output in a procedure?


A parameter is always in input parameter.
To declare the parameter to be output as well, write this

CREATE PROCEDURE dbo.spSomeNameHere
(
@Param1 INT,
@Param2 DATETIME OUT
)
AS

SET NOCOUNT ON

...
...


E 12°55'05.25"
N 56°04'39.16"

Edited by - SwePeso on 12/19/2007 12:58:36
Go to Top of Page

SQLIsTheDevil
Posting Yak Master

USA
177 Posts

Posted - 12/19/2007 :  12:55:32  Show Profile  Reply with Quote
No, I think you misunderstood. I meant how do define a paramter as both input and output, not just one or the other?
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

Sweden
30114 Posts

Posted - 12/19/2007 :  12:58:16  Show Profile  Visit SwePeso's Homepage  Reply with Quote
quote:
Originally posted by SQLIsTheDevil

No, I think you misunderstood. I meant how do define a paramter as both input and output, not just one or the other?


I thought I explained it perfectly well.
Ok, I will try again.

A parameter is ALWAYS in input parameter. You can't change that.
If you want a certain parameter to be BOTH input AND output parameter (as I wrote before "as well") then add the OUT keyword after the datatype for the parameter.

Still confusing?



E 12°55'05.25"
N 56°04'39.16"

Edited by - SwePeso on 12/19/2007 12:58:52
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52309 Posts

Posted - 12/19/2007 :  13:06:01  Show Profile  Reply with Quote
By default you can pass a value through parameter (Input). If you want value to be taken back from parameter as well define it as OUTPUT.
Go to Top of Page

jezemine
Flowing Fount of Yak Knowledge

USA
2885 Posts

Posted - 12/20/2007 :  08:51:48  Show Profile  Visit jezemine's Homepage  Reply with Quote
t-sql syntax make no distinction between inout and out. they are both marked with the OUTPUT keyword.

as a programmer, you might make a distinction in that if the proc returns exactly the same results for all values of an out param, you might refer to it as a pure out param, because the param is not used as input. if its behavior changes, then you might call it an inout param.


elsasoft.org
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.09 seconds. Powered By: Snitz Forums 2000