You should be able to do this with no problem whatsoever. I use temp tables
all the time in my stored procedures
Are you explicitly dropping the temp table in your SP? If so, then don't do
that. Just let it fall out of scope.
Also, are you doing dynamic SQL? Returning multiple resultsets? Just trying
to think what might be going on.

Signature
Bruce Loehle-Conger
MVP SQL Server Reporting Services.
> We have several SPs that you temporary tables to return the data. When
> calling those sps in RS 2k5, they return an error say #temp table is not
[quoted text clipped - 4 lines]
> We can work around it by using the table variables, but would like to know
> if there is a better solution
Thanks for your response, I removed the drop tables deleted the dataset and
re added it, and get the following error
Invalid object name '#temptable'. (Microsoft SQL Server, Error: 208)
For help, click:
http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdV
Also we are not doing dynamic SQL.

Signature
http://www.howisitdone.com
http://www.voipdetails.com
> You should be able to do this with no problem whatsoever. I use temp tables
> all the time in my stored procedures
[quoted text clipped - 13 lines]
> > We can work around it by using the table variables, but would like to know
> > if there is a better solution
Bruce L-C [MVP] - 14 Jun 2006 21:50 GMT
Very odd. Your SP does not even have a table called #temptable. Try creating
a new report just to make sure nothing is still lurking in the old report.
Also, make sure you can execute this from Management Studio.

Signature
Bruce Loehle-Conger
MVP SQL Server Reporting Services
> Thanks for your response, I removed the drop tables deleted the dataset
> and
[quoted text clipped - 28 lines]
>> > know
>> > if there is a better solution
Here is the actual SP
ALTER Procedure [dbo].[sp_jNewAging]
@AgingDate smalldatetime,
@OfficeID int
AS
set nocount on
create table #tAgingDetail (
cusID int,
locationID bigint,
orderID bigint,
Completed smalldatetime,
OrderDue money)
insert into #tAgingDetail
select s.cusid, s.locationid, s.orderid, s.issuedate,
s.saletotal - isnull((select sum(p.payamount)
from payment p
where p.orderid = s.orderid
and p.paydate <= @AgingDate), 0) 'OrderDue'
from vnewsales s
where s.officeid = @OfficeID
and s.issuedate <= @AgingDate
create table #tAgingSummary (
cusID int,
dTotal money,
dCurrent money,
d30 money,
d60 money,
d90plus money,
lpDate smalldatetime,
lpType varchar(16),
lpAmount money)
insert into #tAgingSummary (cusID, dTotal, dCurrent, d30, d60, d90plus)
select tad1.cusid, isnull(sum(tad1.OrderDue), 0),
isnull((select sum(tad2.OrderDue)
from #tAgingDetail tad2
where tad2.cusid = tad1.cusid and
tad2.Completed >= dateadd(minute, 1, @AgingDate) - 30), 0),
isnull((select sum(tad3.OrderDue)
from #tAgingDetail tad3
where tad3.cusid = tad1.cusid and
tad3.Completed between dateadd(minute, 1, @AgingDate) - 60 and @AgingDate-
30), 0),
isnull((select sum(tad4.OrderDue)
from #tAgingDetail tad4
where tad4.cusid = tad1.cusid and
tad4.Completed between dateadd(minute, 1, @AgingDate) - 90 and @AgingDate
- 60), 0),
isnull((select sum(tad5.OrderDue)
from #tAgingDetail tad5
where tad5.cusid = tad1.cusid
and tad5.Completed <= @AgingDate - 90), 0)
from #tAgingDetail tad1
group by tad1.cusid
having isnull(sum(tad1.OrderDue), 0) != 0
--drop table #tAgingDetail
update #tAgingSummary set lpDate = r.entered, lpType = t.typename, lpAmount
= r.recamount
from receipts r
inner join rectype t on r.rectypeid = t.rectypeid
where r.entered <= @AgingDate
and r.recid = (select max(r2.recid) from receipts r2 where r2.cusid =
#tAgingSummary.cusid and r2.rectypeid <= 2)
select c.cusname, c.phone, a.*
from #tAgingSummary a
inner join customer c on c.cusid = a.cusid
order by c.cusname
--drop table #tAgingSummary
set nocount off

Signature
http://www.howisitdone.com
http://www.voipdetails.com
> You should be able to do this with no problem whatsoever. I use temp tables
> all the time in my stored procedures
[quoted text clipped - 13 lines]
> > We can work around it by using the table variables, but would like to know
> > if there is a better solution
Vishnu Sunkara - 15 Jun 2006 21:03 GMT
I have the same problem with temporary table with SQL 2005. I think it is a
bug in Reporting Services
The work around I did is by deleting set nocount on from the stored
procedure.
> Here is the actual SP
>
[quoted text clipped - 100 lines]
>> > know
>> > if there is a better solution
Bruce L-C [MVP] - 17 Jun 2006 15:47 GMT
Ahh, I have wondered why some people see this and I never have had a
problem. I only use this in SP that are not used in RS. My RS stored
procedures I just never include it. I'll run a test on Monday and see what
happens.

Signature
Bruce Loehle-Conger
MVP SQL Server Reporting Services
>I have the same problem with temporary table with SQL 2005. I think it is a
>bug in Reporting Services
[quoted text clipped - 107 lines]
>>> > know
>>> > if there is a better solution
Gold_dust - 21 Jun 2006 22:17 GMT
Hi. What is the latest with this bug? Is it a known RS2k5 issue?
Like the previous posters, I have a lot of stored procs referencing
#temp tables that I was using fine with Management Studio and Crystal
Reports. I tried commenting the nocount on, and i still get at an
error. Please help.
> Ahh, I have wondered why some people see this and I never have had a
> problem. I only use this in SP that are not used in RS. My RS stored
[quoted text clipped - 124 lines]
> >>> > know
> >>> > if there is a better solution
Bruce L-C [MVP] - 21 Jun 2006 22:23 GMT
75 + percent of my stored procedures use temp tables with absolutely no
problems. I have never seen this problem. I suggest opening a support
incident.

Signature
Bruce Loehle-Conger
MVP SQL Server Reporting Services
> Hi. What is the latest with this bug? Is it a known RS2k5 issue?
> Like the previous posters, I have a lot of stored procs referencing
[quoted text clipped - 138 lines]
>> >>> > know
>> >>> > if there is a better solution
CSQL - 05 Jul 2006 14:56 GMT
Did anyone open a support incident for this? I am also receiving the same
error: " There is an error in the query. Invalid object name: #tmporders".
I have deleted the Set No Count statement and it still errors.
My stored procedure is built exactly like user:VOIPDetails.
Thanks
> 75 + percent of my stored procedures use temp tables with absolutely no
> problems. I have never seen this problem. I suggest opening a support
[quoted text clipped - 142 lines]
> >> >>> > know
> >> >>> > if there is a better solution
Gold_dust - 18 Jul 2006 20:26 GMT
Unfortunately, this Microsoft "Expert" refutes all evidence the users
have provided. I did not end up opening an incident. I just had to
convert all of my temp tables into subqueries. Maybe in the next
service pack?
> Did anyone open a support incident for this? I am also receiving the same
> error: " There is an error in the query. Invalid object name: #tmporders".
[quoted text clipped - 155 lines]
> > >> >>> > know
> > >> >>> > if there is a better solution
Bruce L-C [MVP] - 18 Jul 2006 21:03 GMT
Well excuse me. Pretty snotty for someone I was trying to help.
If I don't see the problem I can't tell you what to do. One person (not me)
saw a difference with set no count on.
If I ever find out what people are doing that ends up causing this not to
work then I will pass that on.

Signature
Bruce Loehle-Conger
MVP SQL Server Reporting Services
> Unfortunately, this Microsoft "Expert" refutes all evidence the users
> have provided. I did not end up opening an incident. I just had to
[quoted text clipped - 172 lines]
>> > >> >>> > know
>> > >> >>> > if there is a better solution