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
 returning table from stored procedure ????

Author  Topic 

SanjaySutar
Starting Member

18 Posts

Posted - 2008-04-09 : 07:01:34
How to return an entire table from stored procedure ????

thanx in advance

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-04-09 : 07:11:15
Use

SELECT * FROM Table



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

SanjaySutar
Starting Member

18 Posts

Posted - 2008-04-10 : 21:35:25
Hi thanx 4 the reply

But i just want to retun entire table as a single object from a
stored procedure
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-04-11 : 01:52:29
CREATE PROCEDURE dbo.uspMyProcedure
AS

SELECT * FROM Table



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

jezemine
Master Smack Fu Yak Hacker

2886 Posts

Posted - 2008-04-11 : 02:20:36
if you mean you want to return a table variable from the proc, you can't do that. procs can data in 3 ways only:

1. as results sets, as Peso has demonstrated
2. as (scalar) output params
3, as integer return codes

EDIT: actually there are other ways procs can effectively return data. global temp tables for example, or permanent tables for that matter. it's questionable to call this "returning data" however. It's more of a side-effect. in any case this is worth a read: http://sommarskog.se/share_data.html




elsasoft.org
Go to Top of Page
   

- Advertisement -