Ctreating temp table inside Exec command.
Posted on 2004-03-29
I have used the temp table inside my Exec statement. And If I tried to re use that temp table after Exec,it gave error as #output1 (this is name of temp table) not found .
What is the solution for this.
I need to use Exec coz I need to create a dynamic query depending on the input.
Please help me on this.
My proc is as below
create procedure ParentTest1
select @sql = "SELECT od.orderID orderDetailID,o.parentOrderID tmpParentOrderID ,o.orderID,
FROM tmpOrders o, tmpOrderDetail od
WHERE o.orderID *= od.orderID"+@whereClause
select * from #output1
I think life of #output1 will end as soon as we complete Exec . Is this rt? Do u guys have any other solutions?
Thanks a lot for ur suggestion.