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
 Need Help regarding a stored Procedure

Author  Topic 

udayr
Starting Member

2 Posts

Posted - 2009-08-11 : 13:09:54
Hello Guys..

I am quite new to SQL Server....I have a question regarding a stored procedure...Here is the question..

I have a stored procedure :

-StoredProcedure1 that select certains rows from bunch of tables..

- I also have storedprocedure2 in which I have to populate a temp table with rows returned by executing the storedprocedure1...

Is it possible in StoredProcs..I appreciate any help in clarifying this...thanks...
Uday

Udayr

rajdaksha
Aged Yak Warrior

595 Posts

Posted - 2009-08-11 : 13:14:28
Hi

Am not getting your point. why you are create Procedure two.
In stored procedure one itself you can store the values from SELECT statement...IF am in wrong correct me...




-------------------------
R..
http://code.msdn.microsoft.com/SQLExamples/
http://msdn.microsoft.com/hi-in/library/bb500155(en-us).aspx
Go to Top of Page

udayr
Starting Member

2 Posts

Posted - 2009-08-11 : 13:44:30
Hi..Thanks for the reply...

I have also thought of the same...but the storedProcedure1 to be used in storedproc2 is based in the input parameters...

Here is wat I am thinking of the solution...

create stored proc2
@ storedProc1
create a temp table 'TEMP'

Insert into TEMP
exec (@storedProc1)

..........




Udayr
Go to Top of Page

rajdaksha
Aged Yak Warrior

595 Posts

Posted - 2009-08-11 : 13:50:43
HI

Here what is ur problem....
I think this is fine...


create proc proc1
as
BEGIN
SELECT
COL1,
COL2
INTO #temp
FROM TABLE_NAME
WHERE 1=1
SELECT * FROM #TEMP

DROP TABLE #temp

END






-------------------------
R..
http://code.msdn.microsoft.com/SQLExamples/
http://msdn.microsoft.com/hi-in/library/bb500155(en-us).aspx
Go to Top of Page
   

- Advertisement -