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
 Transact-SQL (2000)
 problem with stored procedure and temparory table

Author  Topic 

shubhada
Posting Yak Master

117 Posts

Posted - 2006-04-14 : 04:09:45
I am working on migration project sybase to sql.
i have a query related to stored procedure and temparory table used in procedure.
i have two procedure proc1 and proc2.
In proc1 i am creating one temparory table a n also calling proc2 in proc1.The temparory table which is created in roc 1 is used in proc 2 as follow.
create proc proc1
as
begin
---
----
---
create table #temp
(
val1 varchar(10)
val2 varchar(10)
)
exec proc2
---
---
drop table #temp
----
----
return
end

Now i want to modify proc2 and trying to execute the modified proc2 but i got the error as follow
Invalid object #temp.

Please help me to overcome this problem.
how i can execute the proc2 which refer the temparory table,created in the proc1.





shubhada

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-04-14 : 06:41:52
You cant access the temp table used in proc1 as the scope is expired after the execution of proc1. You need to make use of global temp table instead. Give more details on what you are trying to do

Madhivanan

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

mmarovic
Aged Yak Warrior

518 Posts

Posted - 2006-04-14 : 07:40:55
So you need to create temp table first then to execute proc2. Otherwise there is no point executiong proc2.
Go to Top of Page

shubhada
Posting Yak Master

117 Posts

Posted - 2006-04-14 : 12:45:43
as per the requirment i need to change the logic of proc2.
Here i passed some parameter to proc1,calacultion will bo done and the calculated value will be inserted into #temp table.And these inserted value is used in proc2 which called in proc1.
can i use the packages for the same but i have no idea about the packages .Please tell me if it is possible.

shubhada
Go to Top of Page
   

- Advertisement -