Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
pavlos
Yak Posting Veteran
59 Posts |
Posted - 2012-04-16 : 03:40:25
|
Hey guysI have a report that runs a query such as this:SELECT name, state, regionFROM detailswhere region in (@region)Now this is fine..But i want to create a query to get my region values:eg.SELECT distinct regionFROM regionWhere pasta in ('2','23')and part = 'west'So my question isI want to assign a whole lot of different region numbers in an 'available value' list in the parameter box.I want to call a quey that returns a field and not just the first result in a set and assign that to a name.Is this possible?FOR EXAMPLEin the parameter sectionavailable values: (specify)label valueregion 1 sql statementregion 2 sql statementcan this be done?where can I store these sql statement? |
|
sunitabeck
Master Smack Fu Yak Hacker
5155 Posts |
Posted - 2012-04-16 : 07:18:17
|
If I understood you correctly, in the "Available Values" tab of the parameter properties dialog, you can select the "Get values from a query" option to accomplish this. You will need to add a dataset that returns the regions available (using your second query). |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-04-16 : 12:21:30
|
you can use option from query option for getting the value. However, keep in mind that you can pass a comma separated list of values into query through a variable and use IN to filter on them. for that you need eithrr dynamic sql or use string parsing function to get into a table and filter using it.seehttp://vyaskn.tripod.com/passing_arrays_to_stored_procedures.htm------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
pavlos
Yak Posting Veteran
59 Posts |
Posted - 2012-04-16 : 22:04:34
|
I have added the value in a datasetbut it will only allow me to use the first value or that dataset in an available value. |
|
|
pavlos
Yak Posting Veteran
59 Posts |
Posted - 2012-04-16 : 22:23:33
|
ok let me restructre my question.I want to specify 3 vales.Label 1:Region AValue:SELECT regionid FROM xxxLabel 2:Region BValue:SELECT regionid FROM xxxLabel 3:Region CValue:'1231','2131','1231' I have saved the 'select regionid' sql statements in a dataset but dont know how to enter them in to the values. |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-04-17 : 13:37:06
|
you specify values by use of parameters.see how you need to setup parameters for it to accept comma seperated list of values in last link------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
|
|
|