My problem is that I was not able to declare parameters through Report Builder.

I was receiving the following error:

ERROR [42000] [Microsoft][ODBC SQL Server Driver][SQL Server]Must declare the scalar variable "@param".

So I googled it and found that it can be solved easily by putting symbol "?" instead of "@parameter" and it did solved my problem for a while.

But now I have another problem. I have a select like:

select * from table t where t.date = ? or t.date2 = ? or t.date3 = ?

Where all three "?" are '2013-aug-01', but each "?" creates a new parameter in the parameters section of Report Builder.

How can I use one parameter for all three cases?

有帮助吗?

解决方案

Try this

select * from table t where ? IN (t.date, t.date2, t.date3)

Another way of solving is just delete the two variables created by SSRS and update your query to

select * from table t where t.date = @param1 or t.date2 = @param1 or t.date3 = @param1

Another method write your query

select * from table t where t.date = ? or t.date2 = ? or t.date3 = ?

Let it create the 3 variables. Then go to Dataset, under dataset properties goto parameters section. There update the parameter value of 2 & 3 to Parameter1. Next go in the parameters section and delete the automatically generated Parameter2 & Parameter3.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top