Can I use @table variable in SQL Server Report Builder?

edosoft picture edosoft · Apr 23, 2010 · Viewed 12.7k times · Source

Using SQL Server 2008 Reporting services:

I'm trying to write a report that displays some correlated data so I thought to use a @table variable like so

DECLARE @Results TABLE (Number int
                       ,Name nvarchar(250)
                       ,Total1 money
                       ,Total2 money
                       )

insert into @Results(Number, Name, Total1)
select number, name, sum(total)
from table1
group by number, name

update @Results
set total2 = total
from
(select number, sum(total) from table2) s
where s.number = number

select from @results

However, Report Builder keeps asking to enter a value for the variable @Results. It this at all possible?

EDIT: As suggested by KM I've used a stored procedure to solve my immediate problem, but the original question still stands: can I use @table variables in Report Builder?

Answer

gbn picture gbn · Aug 4, 2010

No.

ReportBuilder will

  1. 2nd guess you
  2. treats @Results as a parameter