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
 General SQL Server Forums
 New to SQL Server Programming
 Another Beginner SP Question

Author  Topic 

WeeBubba
Starting Member

18 Posts

Posted - 2006-12-08 : 18:44:10
if i am creating an SP then i only specify output parameters if the SP is to return a single set of values. is that correct? if my SP is returning multiple rows from a SELECT statement then i would not specify any parameters on the SP. can somebody clarify this for me. thanks!

snSQL
Master Smack Fu Yak Hacker

1837 Posts

Posted - 2006-12-08 : 18:50:37
Correct
Go to Top of Page

samuelclay
Yak Posting Veteran

71 Posts

Posted - 2006-12-08 : 19:08:05
If you are returning one type of object ( a record set, a value), then you don't need to specify any parameters as OUTPUT, you simply do a select at the end of the procedure.

to return a record set:
....
SELECT RowId, CreateTime
FROM MyTable

to return a single value:
....
SELECT @MyVal as ReturnField

to return a set of values:
....
SELECT @MyVal1 as ReturnField1, @MyVal2 as ReturnField2, @MyVal3 as ReturnField3
These 2 examples return a record set with a single row. These could have been returned as OUTPUT parameters as well, but some people prefer to do it through a select.


If you need to return a value along with a selected result set (like above) then you would want to have output variables set up for the values you need that are outside the results you are returning with your final recordset.

There are many ways of getting data from SQL, your front end language and your dev standards will affect the choices you make.
Go to Top of Page
   

- Advertisement -