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)
 SELECT query stmt inside a Stored Procedure

Author  Topic 

sqlpgmr
Starting Member

4 Posts

Posted - 2005-11-21 : 08:07:12
Friends,

What are the possible usuages of a SELECT query stmt inside a stored procedure ??

How can we process the results of the SELECT query other than for documentation/Reporting purposes(Correct me if i'm wrong in this) ??

can any one throw some lite on this ..

Thanks,
SqlPgmr

surendrakalekar
Posting Yak Master

120 Posts

Posted - 2005-11-21 : 08:12:04
quote:
Originally posted by sqlpgmr

SELECT query stmt inside a stored procedure ??

How can we process the results of the SELECT query other than for documentation/Reporting purposes(Correct me if i'm wrong in this) ??
Thanks,
SqlPgmr



Use of SELECT inside SP is to select the records.
There are number of ways to process the result. Either you can do it by using subquery, storing into temp table, using cursor etc.. etc..
or user can process those records in front-ent (if required)

Read BOL for more information.

Surendra
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-11-21 : 08:41:19
>>What are the possible usuages of a SELECT query stmt inside a stored procedure ??

It depends on what you are going to do with that resultset

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

sqlpgmr
Starting Member

4 Posts

Posted - 2005-11-21 : 08:41:44
Thanks Surendra for the Quick response.

Yes i understand.

If i've a simple proc like this

CREATE PROCEDURE sp_test
AS
BEGIN
SELECT * FROM EMPLOYEE
END

and when i called the PROC within a procedure , is there any possibility of using this result set in the calling procedure???
Go to Top of Page

surendrakalekar
Posting Yak Master

120 Posts

Posted - 2005-11-21 : 08:47:11
quote:
Originally posted by sqlpgmr

and when i called the PROC within a procedure , is there any possibility of using this result set in the calling procedure???


By executing proc within proc you can process/use it. To process/use resultset you can use Temp table/cursor's.
READ BOL.

Surendra
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-11-21 : 09:02:41
Inside calling Procedure, use a table and assign values to it
Insert into yourtable EXEC yoursp 'params' -- if any

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -