Friday, March 30, 2012

Report/query parameter default values

I am using a SQL stored procedure for a report. The sproc has a variable in it (@.itemnumber) to be supplied by the user at run time. In the report parameters within Visual Studio Designer, I am trying to set a default value for the parameter of % so that all items will be returned unless the user enters a specific item number. In the Visual Studio preview this works but once the report is deployed to the web server, the default value does NOT show up. Please advise.

thanks!

Martha

Hi Martha,

SQL Server 2005 Books Online contains an example that takes you through

exactly what it sounds like you are trying to accomplish. Please

take a look at it at:

SQL Server 2005 Books Online->SQL Server 2005

Tutorials->Reporting Services Tutorials->Using a Dynamic Query in

a Report

It shows you how to build a dynamic query to return all records when no parameter is passed through.

If you have further problems after looking at that, please continue posting.|||

Only problem is that we are still on SQL RS 2000. Have not gone to 2005 as yet. Would the information you refer to work on 2000?

thanks!

|||Well let's try to tackle it a different way. Is your query

dynamic and includes a union with your default value that you want to

show all? For example:

SELECT 0 AS DepartmentID, 'All' AS Name

UNION

SELECT DepartmentID, Name

FROM HumanResources.Department

ORDER BY Name|||No, it's a non-queried default. I'm simply trying to set it to %. The variable is a string (varchar) in the sproc. In the Visual Studio preview it works, just not on the web once deployed.|||

hi,

iam also not able to use the dynamic query in repoting services,in sql server 2005.

i am trying from the following path

SQL Server 2005 Books Online->SQL Server 2005 Tutorials->Reporting Services Tutorials->Using a Dynamic Query in a Report-->Lesson 6: Updating the Employees Dataset with a Dynamic Query

as given in the boks online the following query

="SELECT c.firstname, c.lastname, e.title, d.departmentID " &

"From HumanResources.EmployeeDepartmentHistory D " &

"INNER JOIN HumanResources.Employee E " &

"ON D.EmployeeID = E.EmployeeID " &

"INNER JOIN Person.Contact C " &

"ON E.ContactID = C.ContactID " &

Iif(Parameters!Department.Value = 0, "", "WHERE D.DepartmentID = " & Parameters!Department.Value) &

"ORDER BY C.LastName" but am getting error from the if clause,so how to use the dynamic query for the above so.please do replysekhar|||

I am not worked on dynamic queries but i suggest you can use stored procedures with a parameter. Create a stored procedue and pass your parameter to stored procedure.

No comments:

Post a Comment