Showing posts with label parameters. Show all posts
Showing posts with label parameters. Show all posts

Wednesday, March 21, 2012

Dynamix mdx query

I'm not to familiar with mdx, so I don't manage to create a dynamix mdx query in RS against my AS cube. What I'm looking for is having two parameters @.par1 and @.par2 that decide what dimensions to query against. The default query I get when I create a mdx with designer looks like the one below. The problem is that instead of [Product].[Product].[Product] and [Supplier].[Supplier].[Supplier] I would like to use my parameters. The parameters can contain the value Supplier, Product, Customer and all other names of the valid dimensions.I thought maybe it was possible to do somthing like this: [@.par1].[@.par1].[@.par1], but that didnt work :-) I have also tryed using with and set, but havnt managed to make it work. I have seen a couple examples on the forum that I didnt manage to use (http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=443401&SiteID=1, http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=520011&SiteID=1, http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=766277&SiteID=1), but I think these are mostly working with mesures not dimensions.SELECT

NON EMPTY

{

[Measures].[Amount]

}

ON COLUMNS,

NON EMPTY

{

([Product].[Product].[Product].ALLMEMBERS *

[Supplier].[Supplier].[Supplier].ALLMEMBERS)

}

DIMENSION PROPERTIES MEMBER_CAPTION, MEMBER_UNIQUE_NAME ON ROWS FROM [Purchase]

CELL PROPERTIES VALUE, BACK_COLOR, FORE_COLOR, FORMATTED_VALUE, FORMAT_STRING, FONT_NAME, FONT_SIZE, FONT_FLAGSAny sugestions how to solve my problem?

Starting to get a bit desperat with this problem.

I don't manage to use parameters in my MDX query. I have added them in the parameter in the settings of the dataset, but it doesnt help. In regular SQL's it is very easy but I have problem seeing what wrong in the MDX.

Hopefully somone have the answer

|||

Shamefull *bump*

Do really no one know hwo to do this?

|||

It is possible. You need to use the StrToSet function.

SELECTNON EMPTY

{

[Measures].[Amount]

}

ON COLUMNS,NON EMPTY

StrToSet("[" + @.prm1 + "].[" + @.prm1 + "].[" + @.prm1 "].ALLMEMBERS")
*
StrToSet("[" + @.prm2 + "].[" + @.prm2 + "].[" + @.prm2 "].ALLMEMBERS")

DIMENSION PROPERTIES MEMBER_CAPTION, MEMBER_UNIQUE_NAME ON ROWS FROM [Purchase]

CELL PROPERTIES VALUE, BACK_COLOR, FORE_COLOR, FORMATTED_VALUE, FORMAT_STRING, FONT_NAME, FONT_SIZE, FONT_FLAGS

|||

Adam Tappis - IMGroup wrote:

It is possible. You need to use the StrToSet function.

SELECTNON EMPTY

{

[Measures].[Amount]

}

ON COLUMNS,NON EMPTY

StrToSet("[" + @.prm1 + "].[" + @.prm1 + "].[" + @.prm1 + "].ALLMEMBERS")
*
StrToSet("[" + @.prm2 + "].[" + @.prm2 + "].[" + @.prm2 + "].ALLMEMBERS")

DIMENSION PROPERTIES MEMBER_CAPTION, MEMBER_UNIQUE_NAME ON ROWS FROM [Purchase]

CELL PROPERTIES VALUE, BACK_COLOR, FORE_COLOR, FORMATTED_VALUE, FORMAT_STRING, FONT_NAME, FONT_SIZE, FONT_FLAGS

Thanks alot for the reply! I'm really desperate

It seems I'm closer to a solution but still have one problem. I get the following error message:

Query preparation failed.

Parser: The query contains the pmr1 parameters, wich is not declared.

I tryed to add the parameters manually in the parameters tab in the dataset information tab, but that didnt help. Usally when working with SQL and procedures they usally manage to populate the parameter list them self. I probably need to declare the variables directly in the mdx window. Tryed a couple of combinations using WITH and SET, but didnt really manage to get it to work.

Any more help would be really apreciated!

|||

There's 2 places you need to check:

1. Report Menu -> Report Parameters
Make sure the paramter exists (without the @. sign). This should be enough to run the report and look at it in the preview tab

2. In the Data view, click the button that has an @. sign on the dataset window toolbar
This is where you define values for the parametrs used in the query that will be used when you execute the query in this view. Add the parameter (without the @. sign) and specify a value for it.

Clicking the execute button in the toolbar should show you the results.

Hope this helps.

|||

Adam Tappis - IMGroup wrote:

There's 2 places you need to check:

1. Report Menu -> Report Parameters
Make sure the paramter exists (without the @. sign). This should be enough to run the report and look at it in the preview tab

2. In the Data view, click the button that has an @. sign on the dataset window toolbar
This is where you define values for the parametrs used in the query that will be used when you execute the query in this view. Add the parameter (without the @. sign) and specify a value for it.

Clicking the execute button in the toolbar should show you the results.

Hope this helps.

Nr 1 I had done or else I couldnt add them in the details of the dataset. But I didnt notice the parameter button (nr2) the mdx bar! When I added the name with a default value it worked as I wanted it too! Thanks alot I for the help, your a life saver!

|||

Lol I was a bit too quick to say that the problem was solved! I still have problem getting it to work

The problem is when I add pmr1 to the mdx parameter field is that I have to set default value. But when I change this parameter in the report I get 0 result on the dimension. Since the names of the fields becomes the same as the default value I tryed to create a calculated field to get the data to the report and get the value for the calculated field like this: =Fields(Parameters!pmr1.Value).Value. But this also only work if I use the default values set in the mdx toolbar.

Not sure if what I write here is understandable, feel free to ask question if I didnt make clear my problem. Thanks.

|||

Adam Tappis - IMGroup wrote:

There's 2 places you need to check:

1. Report Menu -> Report Parameters
Make sure the paramter exists (without the @. sign). This should be enough to run the report and look at it in the preview tab

2. In the Data view, click the button that has an @. sign on the dataset window toolbar
This is where you define values for the parametrs used in the query that will be used when you execute the query in this view. Add the parameter (without the @. sign) and specify a value for it.

Clicking the execute button in the toolbar should show you the results.

Hope this helps.

With regard to what I said before, doing number 1 will be enough to get this working if configured correctly.

Number 2 and the default value you define there is ONLY used when you want to preview the results of your query in the data tab and does not effect the report at run time e.g. through browser or preview tab. Only the parameter definition in the report parameters window effects run-time execution.

You shouldn't be using any expression syntax at all (unless you are connecting via OLEDB but let's not get into that)

Have are your parameters configured? Datatypes, options, values, manually defined or dataset driven?

|||

Hi, thanks for the response again.

I still have some problems getting it to work as explained. I'll try to give a bit more info.

If I only do 1. then I get error message when trying to leave the data tab becouse the "Query preparation failed". When I also do 2 it works fine but only with the default values I set as parameter on the mdx toolbar.

I have tryed creating the report parameters first and also tryed to let reporting services create the parameters when I add them in the mdx toolbar. No diffrence. Datype is string. No options set. I have tryed with values manually set and without any values. No diffrence.

Maybe there is a diffrence in version from the one I use and the one you use? My version of Reporting Services is 9.00.2047.00.

Any sugestions?

DynamicValuesUnavailable state using wsRS.GetReportParameters

Hi,
I am using the webservice ReportingService from the Reporting Services Web
Service Library.
I'm having a problem when retrieving Parameters for a RS report, valid
values are not returned when they are QueryBased.
It works fine when accessing the report through the RSServerName/reports
virtual dir. Then a dropdown with valid values for the parameter is perfectl
y
populated. As far as I know the "Reports" website uses the ReportingServices
WebService methods?!
When parameters are return from the GetReportParameters method, the
ReportParameters array is correct populated at first glance. The parameters
prm.ValidValuesQueryBased is True, but further investigation reveals that th
e
prm.ValidValues is nothing (VB) and the prm.State of the parameter is
DynamicValuesUnavailable. The prm.ValidValues is supposed to be an array of
the ValidValue class.....
I cannot seem to find any documentation why the prm.State is
DynamicValuesUnavailable. Has anyone tried this, and does anyone know a
solution?
Thanks GlennI have now found the answer to my question. So for your information if anyon
e
should need it:
When invoking the method GetReportParameters on the ReportingServices
service be sure to pass True as value for the ForRendering parameter. When
this is done ValidValues are returned!
/Glenn
"Glenn S?rensen" wrote:

> Hi,
> I am using the webservice ReportingService from the Reporting Services Web
> Service Library.
> I'm having a problem when retrieving Parameters for a RS report, valid
> values are not returned when they are QueryBased.
> It works fine when accessing the report through the RSServerName/reports
> virtual dir. Then a dropdown with valid values for the parameter is perfec
tly
> populated. As far as I know the "Reports" website uses the ReportingServic
es
> WebService methods?!
> When parameters are return from the GetReportParameters method, the
> ReportParameters array is correct populated at first glance. The parameter
s
> prm.ValidValuesQueryBased is True, but further investigation reveals that
the
> prm.ValidValues is nothing (VB) and the prm.State of the parameter is
> DynamicValuesUnavailable. The prm.ValidValues is supposed to be an array o
f
> the ValidValue class.....
> I cannot seem to find any documentation why the prm.State is
> DynamicValuesUnavailable. Has anyone tried this, and does anyone know a
> solution?
> Thanks Glenn

DynamicValuesUnavailable state using wsRS.GetReportParameters

Hi,
I am using the webservice ReportingService from the Reporting Services Web
Service Library.
I'm having a problem when retrieving Parameters for a RS report, valid
values are not returned when they are QueryBased.
It works fine when accessing the report through the RSServerName/reports
virtual dir. Then a dropdown with valid values for the parameter is perfectly
populated. As far as I know the "Reports" website uses the ReportingServices
WebService methods?!
When parameters are return from the GetReportParameters method, the
ReportParameters array is correct populated at first glance. The parameters
prm.ValidValuesQueryBased is True, but further investigation reveals that the
prm.ValidValues is nothing (VB) and the prm.State of the parameter is
DynamicValuesUnavailable. The prm.ValidValues is supposed to be an array of
the ValidValue class.....
I cannot seem to find any documentation why the prm.State is
DynamicValuesUnavailable. Has anyone tried this, and does anyone know a
solution?
Thanks Glenn
I have now found the answer to my question. So for your information if anyone
should need it:
When invoking the method GetReportParameters on the ReportingServices
service be sure to pass True as value for the ForRendering parameter. When
this is done ValidValues are returned!
/Glenn
"Glenn S?rensen" wrote:

> Hi,
> I am using the webservice ReportingService from the Reporting Services Web
> Service Library.
> I'm having a problem when retrieving Parameters for a RS report, valid
> values are not returned when they are QueryBased.
> It works fine when accessing the report through the RSServerName/reports
> virtual dir. Then a dropdown with valid values for the parameter is perfectly
> populated. As far as I know the "Reports" website uses the ReportingServices
> WebService methods?!
> When parameters are return from the GetReportParameters method, the
> ReportParameters array is correct populated at first glance. The parameters
> prm.ValidValuesQueryBased is True, but further investigation reveals that the
> prm.ValidValues is nothing (VB) and the prm.State of the parameter is
> DynamicValuesUnavailable. The prm.ValidValues is supposed to be an array of
> the ValidValue class.....
> I cannot seem to find any documentation why the prm.State is
> DynamicValuesUnavailable. Has anyone tried this, and does anyone know a
> solution?
> Thanks Glenn

DynamicValuesUnavailable

I am using the WS interface and returning reports for rendering will our UI.
I am successfully getting back the parameters. I would like to create a
drop down list box where appropriate for the parameters. So i iterate
through the ValidValues[]. This works fine for the exception of when those
values are driven from a secondary dataset in the report. In this case i
get the DynamicValuesUnavailable enum for the State and the ValidValues[] is
undefined value. I believe I have ruled out security in that both the main
report and the drop down are driven from the same shared data source. Any
Ideas?Never mind - need to set ForRendering to true, although the one liner on
msdn below is a little misleading.
ForRendering
A Boolean expression that indicates how the parameter values are to be used.
If set to a value of true, parameter properties that are returned are based
on the parameter data that was used during the execution of the report.
"jsl" <someone@.microsoft.com> wrote in message
news:%23I%23LaIQmFHA.3448@.TK2MSFTNGP12.phx.gbl...
>I am using the WS interface and returning reports for rendering will our
>UI. I am successfully getting back the parameters. I would like to create
>a drop down list box where appropriate for the parameters. So i iterate
>through the ValidValues[]. This works fine for the exception of when those
>values are driven from a secondary dataset in the report. In this case i
>get the DynamicValuesUnavailable enum for the State and the ValidValues[]
>is undefined value. I believe I have ruled out security in that both the
>main report and the drop down are driven from the same shared data source.
>Any Ideas?
>

Monday, March 19, 2012

Dynamically select tables

Hi,
I am writing a stored procedure which needs to select different tables
based on different parameters. I used to use 'CASE' to select
different columns, so I tried to use following statement like "select
* from CASE @.id WHEN 0 then 'EMPLOYEE' END". It doesn't work.
What i need to achieve is dynamically select tables based on
parameters, such like :@.id = 1 then from 'EMPLOYEE', @.id = 0 then from
'ORDER' table.
Could anyone help me with this issue?
ThanksYOu have to use dynamic SQL for this. You can stuck you sql coe
together and execute it then with EXEC or sp_executesql. Dynamic sql
has some limitations and may be the nail to your coffin, the best would
be to read Erlands article first before implementing this:
http://www.sommarskog.se/dynamic_sql.html
HTH, Jens Suessmeyer.|||Ron (rzhou@.mettle.biz) writes:
> I am writing a stored procedure which needs to select different tables
> based on different parameters. I used to use 'CASE' to select
> different columns, so I tried to use following statement like "select
> * from CASE @.id WHEN 0 then 'EMPLOYEE' END". It doesn't work.
> What i need to achieve is dynamically select tables based on
> parameters, such like :@.id = 1 then from 'EMPLOYEE', @.id = 0 then from
> 'ORDER' table.
> Could anyone help me with this issue?
Sounds ugly. Maybe there is reason for a table redesign? Then again,
it could make sense.
Anyway, dynamic SQL is what you need to do this. I have a general
article on dynamic SQL on my web site, and then there is another which
discusses dynamic search conditions in particular.
http://www.sommarskog.se/dynamic_sql.html
http://www.sommarskog.se/dyn-search.html
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspx|||Hi Guys,
Thanks for your help! great articles
Ron|||>> I am writing a stored procedure which needs to select different tables ba
sed on different parameters. <<
Have you thought about what that means in terms of your design?
Assuming that you have a relational schema, each table is a TOTALLY
DIFFERENT KIND OF ENTITY , what will meaningful name will you give this
nightmare? I propose that you use
" Get_squids_or_automobiles_or_Britney_Spe
ars" as the name. It sounds
pretty vague and stupid when you think about it.
Gee, sure sounds like it violates coupling and cohesion -- remember
those fundamentals of programming from your freshman year in Comp Sci?
That is FAR more fundamental than SQL.
You have never read a book on SQL. Not even half a book! The CASE
expression returns a value of a known data type, just like any other
expression. SQL is compiled; you are not writing BASIC.
The stinking, dirty, unmaintainable kludge that you will get on a
Newsgroup is dynamic SQL. That way you can avoid RDBMS and fake 1960's
BASIC code on the fly.
Why won't anyone else tell you this? If we give you that quick answer
or a few links, you will go away. But if someone yells at you for
your lack of fundamentals, then your feeling might be hurt (we assume
you are child, not an adult) or that you will ask questions that will
require serious study and we don't want to post a few quarters of
college level work on a newsgroup.
If you want a REAL answer, we need DDL, a good spec, sample data, etc.
And you might have a horrible schema that needs to be re-done, the
queries might be really hard, etc. Welcome to the real world!!|||Don't be intimidated,... Dynamic sql will do what you wish...That is the
answer to your question.
However, you might wish to ensure you have a good design, and that you are
not making a problem for yourself later... Dynamic SQL does help us solve
problems, and we use it when we need to -
--
Wayne Snyder MCDBA, SQL Server MVP
Mariner, Charlotte, NC
I support the Professional Association for SQL Server ( PASS) and it''s
community of SQL Professionals.
"Ron" wrote:

> Hi,
> I am writing a stored procedure which needs to select different tables
> based on different parameters. I used to use 'CASE' to select
> different columns, so I tried to use following statement like "select
> * from CASE @.id WHEN 0 then 'EMPLOYEE' END". It doesn't work.
> What i need to achieve is dynamically select tables based on
> parameters, such like :@.id = 1 then from 'EMPLOYEE', @.id = 0 then from
> 'ORDER' table.
> Could anyone help me with this issue?
> Thanks
>|||IMO Dynamic sql is possible.
BOL states that you can not use can not us parameters with openRowset and fr
om a
pure technical sense, I guess it's a valid statement. But where there is wi
ll
there is a way.
You can see I build a variable @.SQL based in part on parameters passed to th
e
procedure. Is this not dynamic SQL?
CREATE Procedure usp_GetPeriodLabor @.bp as char(5),@.ep as nvarchar(5) as
Declare @.sql nvarchar(500)
SET @.SQL = 'Select * into tPeriodLabor_tmp from OPENROWSET(''MSDAORA'',
''oralcleinstance'';''user'';''password'
',
''select detail_Date,employee_sys_id,pay_period,L
D_CODE1 as
CostCenter,ld_code2,ld_Code3 as account,
stop_time,start_time, (stop_time-start_time)/60
from easp.timecard_detail
where (pay_Period >= ' +@.bp+' and
detail_date <= ' +@.ep+') and (timecode_sys_id = 128 or timecode_sys_id = 136
or timecode_sys_id = 142 or timecode_sys_id = 163 or timecode_sys_id = 166)'
')'
Exec (@.sql)
GO
-- Posted with NewsLeecher v3.0 Beta 6
-- http://www.newsleecher.com/?usenet

Dynamically retrieve the name of all the parameters for a report.

Does anyone know, if you are inside the body of a report, of a way to have a
textbox dynamically populated with the name of all the parameters that are on
that report?
So, the idea is, this textbox in the body of the report would have some
expression, and that expression would always return the names of all
parameters that are defined for the report. So, if someone changes the report
to use have a new parameter, this textbox would automatically show the name
of that new parameter.
Any help would be greatly appreciated.
Thanks.Sorry, this is not supported at this point.
-- Robert
This posting is provided "AS IS" with no warranties, and confers no rights.
"Mike Barzilli" <Mike Barzilli@.discussions.microsoft.com> wrote in message
news:D21AC308-F48C-4F68-B189-4737E03DFEC1@.microsoft.com...
> Does anyone know, if you are inside the body of a report, of a way to have
> a
> textbox dynamically populated with the name of all the parameters that are
> on
> that report?
> So, the idea is, this textbox in the body of the report would have some
> expression, and that expression would always return the names of all
> parameters that are defined for the report. So, if someone changes the
> report
> to use have a new parameter, this textbox would automatically show the
> name
> of that new parameter.
> Any help would be greatly appreciated.
> Thanks.

Dynamically number of parameters

I have 3 paramemters. How i can dynamically show/hide other two parameter based on the value as 1 or 2 input from the user from the first parameter? (for example: if the user enter 1, i will show the second parameter, if tyhe user enter 2, i will sho the thirs parameter on the report so the user can enter other value in these dynamical parameters?)Thats not possible. What is possible to still display them , but to clean them to show no value. That can be done using a query in the parameter definition.


HTH, Jens Suessmeyer.

http://www.sqlserver2005.de

Dynamically hide parameters

Is there a way to dynamically show/hide the parameter selection for a report? For example, when my report is viewed in Report Manager I want the parameters to be visible, but in our custom app with an embedded report I want them hidden so that the user can use our UI to enter them.
Is this possible?

The ReportViewer control has a ShowParameterPrompts property that can be set to False if you do not want to show the parameter prompts in your custom app. There is also a ShowToolBar property which you could use to hide the rest of the toolbar, so that all the user sees is the actual report.

If you need to leave some parameters visible and hide others, I am not sure, someone else will have to answer that.

Good luck,

Dave

Sunday, March 11, 2012

Dynamically generate SqlDataSource

Hi, how I do create SqlDataSource in thecode-behind,setting Select SQL along with its parameters and, finallyautomically generating Del, Update, Insert SQL.

Is there a way to achieve this goal as it would in VS designer?

Thanks,

Ricky.

It is possible to create the TSQL code and wrapper code automatically by a variety of means. I use TSQL scripts to do the generation from within Query Analyser.

Which version of SQL Server are you targetting?

|||

Hi, I use SQL SERVER 2005

Thanks,

Ricky.

Friday, March 9, 2012

Dynamically changing Web Service Task parameters at runtime?...

Okay, this one might stump you guys.

I am trying to access a web service that has parameters (three of them, all strings). But I want to access this service repeatedly, and drive the thing from a table.

I've got the Foreach Loop correctly getting variables from the recordset I populate from the table. That works and I can run a script with msgbox showing all the correct values being read from the table.

My problem is taking these variables and sticking them in the Name / Type / Value entries in the Input tab of the Web Service Task. There doesn't seem to be any mechanism for dynamically updating these at runtime, and if there isn't, that is a HUGE hole in the product. Who accesses Web Services with the same parameters every time?!?
No doubt you know this by now Lazamataz but this can't be done. you're right, it IS a hole in the product!

-Jamie|||

I'm trying to do this to...

Is there a way of accessing web service parameters through a script and the runtime / tasks?

|||

Absolutely, yes. Buy Donald Farmer's book (available at the usual places). That has a downloadable chapter that shows you how.

-Jamie

Dynamically changing Web Service Task parameters at runtime?...

Okay, this one might stump you guys.

I am trying to access a web service that has parameters (three of them, all strings). But I want to access this service repeatedly, and drive the thing from a table.

I've got the Foreach Loop correctly getting variables from the recordset I populate from the table. That works and I can run a script with msgbox showing all the correct values being read from the table.

My problem is taking these variables and sticking them in the Name / Type / Value entries in the Input tab of the Web Service Task. There doesn't seem to be any mechanism for dynamically updating these at runtime, and if there isn't, that is a HUGE hole in the product. Who accesses Web Services with the same parameters every time?!?
No doubt you know this by now Lazamataz but this can't be done. you're right, it IS a hole in the product!

-Jamie|||

I'm trying to do this to...

Is there a way of accessing web service parameters through a script and the runtime / tasks?

|||

Absolutely, yes. Buy Donald Farmer's book (available at the usual places). That has a downloadable chapter that shows you how.

-Jamie

Wednesday, March 7, 2012

Dynamically adding Select Parameters (Filter)

how do i add parameters like this dynamically? do i need to change the select command? to add the @.ID part?

Although this is for delete you get the idea. This is using a sqldatasource with stored procedures.

protected void SqlPages_Deleting(object sender, SqlDataSourceCommandEventArgs e)
{

// Wipe out the auto params and replace with the correct one.
DbParameterCollection CmdParams = e.Command.Parameters;
DbParameter oParam = null;
foreach (DbParameter cp in CmdParams)
{
//Trace.Warn(cp.ParameterName, Convert.ToString(cp.Value));
if (cp.ParameterName == "@.PageID") {
oParam = cp;
}

}
CmdParams.Clear();
CmdParams.Add(oParam);

//e.Cancel = true;
}

HTH,

|||

You can see the select i am using has a filter as well. Here is the aspx code:

<asp:SqlDataSource ID="SqlPages" runat="server"
ConnectionString="<%$ ConnectionStrings:MonkeyCon %>"
SelectCommand="Pages_SelectPagesBySite"
SelectCommandType="StoredProcedure"
...

<SelectParameters>
<asp:Parameter Direction="ReturnValue" Name="RETURN_VALUE" Type="Int32" />
<asp:ControlParameter ControlID="ddlSiteFilter" Name="SiteID" PropertyName="SelectedValue"
Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>

|||

can i like have an option to display back all? unfiltered? like first i filter by Item Name = "Something", then i want it to be <All> now, how do i do that? something like Select * From SomeTable. no more where...

|||

You could add a branch in your SPROC where if the ID = 0 you return all. And just add an option of <Show All> with a value of 0 to your dropdownlist ..

Dynamic Where clause in Stored Procedure

Hi, I have several parameters that I need to pass to stored procedure but sometimes some of them might be null. For example I might pass @.Path, @.Status, @.Role etc. depending on the user. Now I wonder if I should use dynamic Where clause or should I use some kind of switch, maybe case and hardcode my where clause. I first created several stored procedures like Documents_GetByRole, Documents_GetByRoleByStatus ... and now I want to combine them into one SP. Which approach is better. Thanks for your help.dynamic where clauses would eliminate most of the benefits of the stored procedure.

For every ad-hoc query that's executed, a new execution plan and compiliation takes place. Furthermore, your ram goes up.

A lot of databases will slow down with usage due to this. Therefore, hardcoding your where clauses is best. (like field = @.value)

Sunday, February 26, 2012

Dynamic values in parameters

I have 3 parameters which I populate from 3 sprocs. However, I want the
value selected for sproc1 to determine the possible values in sproc2 and the
selected value in sproc2 to determine the value in sprocs3. How do I go
about this?
Thanks
Frank AshleyFrank,
Search for "Cascading Parameters" in Reporting Services books online.
There's an example for T-SQL which should apply to stored procs.
"Frank Ashley" wrote:
> I have 3 parameters which I populate from 3 sprocs. However, I want the
> value selected for sproc1 to determine the possible values in sproc2 and the
> selected value in sproc2 to determine the value in sprocs3. How do I go
> about this?
>
> Thanks
> Frank Ashley
>
>

Dynamic updating of Parameters.

Hi I am using sql server reporting services 2000 and in a report I have more than 20 parameters of data type Boolean. I want another parameter drop down which have "select all" and "clear all" options. When user select “select all” option from the parameter list all 20 parameters value should be false.

I will be very thankful.

Regards,

Faisal Saleem

Hi Faisal,

try to use "cascading parameters" and "default values".

More info here:
http://msdn2.microsoft.com/en-us/library/ms170246.aspx

cheers

Markus

|||

Firstly cascading/dependent parameters only work when they are populated from a dataset that uses another parameter. This is not the case here as these are boolean parameters.

Secondly, default values are only applied when the report first loads. So once the user changes any of the parameters, default values are no longer considered and hence trying to use use default values with deperndent parameters will not work.

Cascading parameters are used to modify/effect the list of available values rather than the one that's actually selected.

Although at first is seems like this should be possible, I don't think it is.

Instead, can I suggest that you change the "select all" parameter to contain 3 values:

All

None

Custom

|||

Adam Tappis - IMGroup wrote:

Secondly, default values are only applied when the report first loads. So once the user changes any of the parameters, default values are no longer considered and hence trying to use use default values with deperndent parameters will not work.

Cascading parameters are used to modify/effect the list of available values rather than the one that's actually selected.

I just ran into this and it seems like a functional bug to me. It's great that cascading parameters can be used to alter drop-down options for subsequent parameters, but that's only part of the story. If subsequent parameter choices can be altered by a previous parameter selection, it is completely misleading not to do the same for setting defaults. The users find it very confusing.

Anyone know if this has been logged to Connect?

|||

GregsListAcct wrote:

Anyone know if this has been logged to Connect?

Just answered my own question. It is logged in Connect:

http://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=268032

Microsoft is considering it "by design". :^(

Dynamic updating of Parameters.

Hi I am using sql server reporting services 2000 and in a report I have more than 20 parameters of data type Boolean. I want another parameter drop down which have "select all" and "clear all" options. When user select “select all” option from the parameter list all 20 parameters value should be false.

I will be very thankful.

Regards,

Faisal Saleem

Hi Faisal,

try to use "cascading parameters" and "default values".

More info here:
http://msdn2.microsoft.com/en-us/library/ms170246.aspx

cheers

Markus

|||

Firstly cascading/dependent parameters only work when they are populated from a dataset that uses another parameter. This is not the case here as these are boolean parameters.

Secondly, default values are only applied when the report first loads. So once the user changes any of the parameters, default values are no longer considered and hence trying to use use default values with deperndent parameters will not work.

Cascading parameters are used to modify/effect the list of available values rather than the one that's actually selected.

Although at first is seems like this should be possible, I don't think it is.

Instead, can I suggest that you change the "select all" parameter to contain 3 values:

All

None

Custom

|||

Adam Tappis - IMGroup wrote:

Secondly, default values are only applied when the report first loads. So once the user changes any of the parameters, default values are no longer considered and hence trying to use use default values with deperndent parameters will not work.

Cascading parameters are used to modify/effect the list of available values rather than the one that's actually selected.

I just ran into this and it seems like a functional bug to me. It's great that cascading parameters can be used to alter drop-down options for subsequent parameters, but that's only part of the story. If subsequent parameter choices can be altered by a previous parameter selection, it is completely misleading not to do the same for setting defaults. The users find it very confusing.

Anyone know if this has been logged to Connect?

|||

GregsListAcct wrote:

Anyone know if this has been logged to Connect?

Just answered my own question. It is logged in Connect:

http://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=268032

Microsoft is considering it "by design". :^(

Dynamic updating of Parameters.

Hi I am using sql server reporting services 2000 and in a report I have more than 20 parameters of data type Boolean. I want another parameter drop down which have "select all" and "clear all" options. When user select “select all” option from the parameter list all 20 parameters value should be false.

I will be very thankful.

Regards,

Faisal Saleem

Hi Faisal,

try to use "cascading parameters" and "default values".

More info here:
http://msdn2.microsoft.com/en-us/library/ms170246.aspx

cheers

Markus

|||

Firstly cascading/dependent parameters only work when they are populated from a dataset that uses another parameter. This is not the case here as these are boolean parameters.

Secondly, default values are only applied when the report first loads. So once the user changes any of the parameters, default values are no longer considered and hence trying to use use default values with deperndent parameters will not work.

Cascading parameters are used to modify/effect the list of available values rather than the one that's actually selected.

Although at first is seems like this should be possible, I don't think it is.

Instead, can I suggest that you change the "select all" parameter to contain 3 values:

All

None

Custom

|||

Adam Tappis - IMGroup wrote:

Secondly, default values are only applied when the report first loads. So once the user changes any of the parameters, default values are no longer considered and hence trying to use use default values with deperndent parameters will not work.

Cascading parameters are used to modify/effect the list of available values rather than the one that's actually selected.

I just ran into this and it seems like a functional bug to me. It's great that cascading parameters can be used to alter drop-down options for subsequent parameters, but that's only part of the story. If subsequent parameter choices can be altered by a previous parameter selection, it is completely misleading not to do the same for setting defaults. The users find it very confusing.

Anyone know if this has been logged to Connect?

|||

GregsListAcct wrote:

Anyone know if this has been logged to Connect?

Just answered my own question. It is logged in Connect:

http://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=268032

Microsoft is considering it "by design". :^(

Friday, February 24, 2012

dynamic table name in from clause

Hello All,
I am trying to create UDF that will take in tablename and columnname,
maxlength as parameters. Based on the tablename and columnname, I want to
return the length of the longest columndata. If the length value is bigger
than the maxlength parameter, I pass in , I just want to return the
maxlength.
Basically, I am trying to do the following:
alter FUNCTION dbo.rp_MaxColumnLength
(@.TableName varchar(200),@.ColumnName varchar(200),@.MaxLenth INT)
RETURNS INT
AS
BEGIN
DECLARE @.ColMaxLength INT
SELECT @.ColMaxLength = MAX(LEN(@.ColumnName)) FROM @.TableName
if @.colmaxlegth > @.Maxlength
return @.MaxLength
else
return @.colmaxlength
END
But I guess, I cannot use a variable in the FROM clause as a tablename.
Does anyone know a workaround?
Please help.
Thanks, sqlgirlYou might want to start with the following article:
http://www.sommarskog.se/dynamic_sql.html
It has some relevant details and implications of using such approaches.
Anith|||
Hey Amith,
Thanks a bunch. I was able to solve my problem by looking at the
article.
*** Sent via Developersdex http://www.examnotes.net ***
Don't just participate in USENET...get rewarded for it!

Dynamic Subscription Parameters

Ok I've seen this question asked often, but it appears no one has come
up with an answer.
I have a report that is viewed most often though a portal with the
default parameters of startdate (yesterday) and enddate (today). Now
the request has come in for a different group of people to be able to
create their own subscription for this report, but they want to see the
data on a weekly basis.
So the question is... Are there any expressions, bits of code, code
words etc that will be accepted on a user subscript to set the date for
a report (without using the default)
I've tried...
=Today()
=datetime.today.adddays(-1).tostring("mm/dd/yy")
datetime.today
datetime.today(adddays(-7)
NOW
but every time I enter one of those in the parameter box, they revert
to the default value.Why not have the parameter as a flag instead of dates, 1 = daily, 2 =weekly then default the dates used in the query based on the flag?
If the report must be available for ad-hoc runs with date parameters
available to users as well, simply have the flag parameter as well as
date parameters, hide the flag parameter in Report Manager, and default
it to zero to indicate that the date parameter be used instead. Your
data query will be a little more complex but it shouldn't be too bad.
--
Regards
Chris
Ches Weldishofer wrote:
> Ok I've seen this question asked often, but it appears no one has come
> up with an answer.
> I have a report that is viewed most often though a portal with the
> default parameters of startdate (yesterday) and enddate (today). Now
> the request has come in for a different group of people to be able to
> create their own subscription for this report, but they want to see
> the data on a weekly basis.
> So the question is... Are there any expressions, bits of code, code
> words etc that will be accepted on a user subscript to set the date
> for a report (without using the default)
> I've tried...
> =Today()
> =datetime.today.adddays(-1).tostring("mm/dd/yy")
> datetime.today
> datetime.today(adddays(-7)
> NOW
> but every time I enter one of those in the parameter box, they revert
> to the default value.|||Oh I love it when people think out of the box!!!!
Great suggestion. I'll look into implementing today.|||Oh I love it when people think out of the box!!!!
Great suggestion. I'll look into implementing today.

Dynamic Subreports... is it possible?

Is it possible to set up a subreport so that I can determine which report it displays based on parameters? From what I've seen, the report that a subreport displays must be hardcoded... Anyone got any workarounds?

No .... not really. Unfortunately Microsoft did not implement the RDL parameter replacement mechanism very well.

In my opinion, Reporting Services 2005 would have been much stronger if they would have simply taken the input parameter information and replaced all occurrences of the "parameter" within the RDL prior to rendering. How hard can that be?

Here's a link for a terrible work around - a nasty one that uses layering.

http://www.developmentnow.com/g/115_2006_1_0_0_680033/Dynamic-Subreports.htm