Tuesday, September 23, 2008

Custom Value to your Select Query and Pass your Custom Value to Select Query as a Parameter

Here I am adding ‘[All]' as my custom value with my result set here,
For E.g.
Select ‘[All]'' as City
Union
Select distinct City from Table1
If you want ‘[All]'’ option in your Parameter the column name should be same for both select queries and the same column name should be present in both the select queries.
To pass your Custom Value (e.g. ‘[All]'’) to your Select Query as Parameter follow the below procedure,
To Pass this ‘[All]'' in your where condition as a parameter follow the below procedure,
1. Set one parameter
2. Then write the following query in your dataset
Select City, Country, PinCode from Table1
WHERE ((City =@Parameter1) or (@Parameter1='[All]''))
3. Now if you select ‘’ option in your parameter the query will fetch all the City name from Table1 otherwise you have to select a single City Name to fetch a information for a particular City

No comments: