Using Dynamic Queries 

 

You can use expressions in queries to create queries that change based on values in the report. Using dynamic queries, you can alter the basic structure of a query when the report is run. For example, you can write an expression that changes the table or fields from which data is retrieved based on the user's locale information.

Defining a Dynamic Query

You must use the generic query designer to write a query expression. Also, if you use an expression for a query, Report Designer cannot automatically derive fields and parameters from the query. You must manually define all of the fields that the query is expected to return. You must also manually define report and query parameters. One way to simplify this process is to write a normal query that returns the same fields and uses the same parameters that the query expression does. Report Designer can use this query to automatically derive the fields and parameters. After this is done, you can change the query to an expression.

A tutorial demonstrates how to create a report that uses a dynamic query. For more information, see Tutorial: Using a Dynamic Query in a Report.

See Also

Concepts

Retrieving Data from a Data Source

Help and Information

Getting SQL Server 2005 Assistance