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)
 Storing resultset of stored proc in temp table

Author  Topic 

tiaa_ns
Starting Member

16 Posts

Posted - 2001-06-21 : 10:03:21
CREATE STORED PROCEDURE sp_TopProc
(@Query nvarchar(1000))
AS
BEGIN

/*Following is not a valid statement. But I want similar operation*/

SELECT * INTO #Temp FROM
EXECUTE sp_BusinessLogic @Query, @Param

/*Basically I want to have the resultset returned by the sp_BusinessLogic in a temporary table. I've to further use it for updation & processing. @Query is obtained from the end user, So he can have any SELECT command. The query is altered but SELECT statement is same as was passed. The above operation is in loop & once it will be called with SELECT INTO & rest of the time it will use INSERT INTO.*/

END

*********************************************

CREATE STORED PROCEDURE sp_BusinessLogic
(@SqlQuery varchar(1000),
@Param varchar(20))
AS
BEGIN

/*Does something with SqlQuery & ParamCount & get the final SqlQuery after manipulation.
Note: The SELECT command is untouched, only the FROM & WHERE clause may be changed by the code in this procedure.*/

EXEC @FinalSqlQuery

END

*********************************************

Let me know if the problem is not well defined. Thanks in advance for replying.
   

- Advertisement -