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

Monday, March 19, 2012

Collapse the parameters when I click view report

Hi, I am using RS 2005.
I have around 25-30 parameters which cover almost the whole screen, so
when I click on View Report, is it possible to automatically collapse
the parameters part of the window?
Thanks
AnupHi guys,
It's urgent, I am stuck at this and our requirement is when the view
report is clicked or when the report is displayed for the first time,
the parameters part of the report should be automatically collapse?
Thanks
Anup
Anup wrote:
> Hi, I am using RS 2005.
> I have around 25-30 parameters which cover almost the whole screen, so
> when I click on View Report, is it possible to automatically collapse
> the parameters part of the window?
> Thanks
> Anup|||If you are getting to the report via an href add:
&rc:Parameters=False
to the query string
Chris E
"Anup" <anupkm@.gmail.com> wrote in message
news:1166115447.858873.68660@.t46g2000cwa.googlegroups.com...
> Hi guys,
> It's urgent, I am stuck at this and our requirement is when the view
> report is clicked or when the report is displayed for the first time,
> the parameters part of the report should be automatically collapse?
> Thanks
> Anup
> Anup wrote:
>> Hi, I am using RS 2005.
>> I have around 25-30 parameters which cover almost the whole screen, so
>> when I click on View Report, is it possible to automatically collapse
>> the parameters part of the window?
>> Thanks
>> Anup
>

Sunday, March 11, 2012

Code review tool for Stored procedures

Hi,
Is there any tool (freeware or licensed) which can automate code reviews for
stored procedures based on various parameters. I am looking out for somethin
g
similar to FXCop for stored procedures on SQL Server 2000.
Afaq ChoonawalaYou can start with SQL BPA
http://www.microsoft.com/downloads/...&displaylang=en
Regards
Roji. P. Thomas
http://toponewithties.blogspot.com
"Afaq" <Afaq@.discussions.microsoft.com> wrote in message
news:36129FBF-13FB-4492-B7F3-C21C75BD2B7A@.microsoft.com...
> Hi,
> Is there any tool (freeware or licensed) which can automate code reviews
> for
> stored procedures based on various parameters. I am looking out for
> something
> similar to FXCop for stored procedures on SQL Server 2000.
> --
> Afaq Choonawala

Wednesday, March 7, 2012

COALESCE with parameters

I am trying to build a report table based on user supplied criteria at run time. The user may or may not enter criteria into one or more fields. I used the COLAESCE as follows (the temp vars may be passed valid data or left null by the user):

select * from dbo.employee

where LastName>=COALESCE(@.ln,lastname) andLastName<=COALESCE(@.ln2,lastname) andFirstName>=COALESCE(@.fn,firstname) andFirstName<=COALESCE(@.fn2,firstname) andhiredate>=COALESCE(@.hire,hiredate) andhiredate<=COALESCE(@.hire2,hiredate) andcheckdate>=COALESCE(@.chk,checkdate) andcheckdate<=COALESCE(@.chk2,checkdate)

The problem comes when I want to return rows that include columns that may be null. For example the CHECKDATE col might be the date the employee was reviewed and for new employees it may be null. I still want to return that row.

I had thought of creating default values for every column when the user adds a row to a table. I can set all char fields = ' ' and int fields = 0, but what is a valid default value for a date type col that won't cause problems when other procs try to grab the field and use it?

Or is there a better way to use the COALESCE function?

Thanks all!

I would add a third parameter to the coalesce function. For instance COALESCE(@.var,FieldName,'1/1/1900'). The third field would be the "default" value if the first two return null. HTH.

-Chris

|||If you couldn't choose some value as "empty", you could add additional parameter like @.ln_is_empty and then use something like (@.ln_is_empty=1 or (Lastname>=@.ln and @.ln_is_empty=0) )|||

Assuming that the query is contained within a stored procedure then you would have to start by declaring another input parameter per search term to indicate whether the WHERE condition for the relevant column should check for NULL or whether the search term should be ignored (i.e. equal to itself), currently it seems that you have no way to distinguish between the two.

Once this has been done you can use:

WHERE ((checkdate >= COALESCE(@.chk,checkdate) and checkdate <= COALESCE(@.chk2,checkdate))

OR (@.checkdateisnull = 1 AND checkdate IS NULL))

As an aside, with a query such as the one you have presented you are unlikely to see great performance. It might be better to dynamically create and execute a SQL string inside the stored procedure, forget using COALESCE inside the SQL string and include only what's actually needed in the WHERE clause - using COALESCE in the way that you have done is likely to lead to table / index scans and gives little scope for performance improvements by indexing.

Chris

|||

There are better ways to write this query than using COALESCE with column names. The above usage will negate use of any indexes on the columns. So you will be pretty much scanning the entire table for any combination of parameters. See the link below for various techniques that will help you solve the problem. Look for my name to see some techniques that use COALESCE/ISNULL but with better results. Erland also covers in detail other techniques that will help you get the best results.

http://www.sommarskog.se/dyn-search.html

|||

Thanks!!!

I'll be studying that document for quite some time!

Saturday, February 25, 2012

cmd.Parameters question?

I have several parameters that are passed to a stored procedure. One of them is a website URL. How can I strip out the http:// if it exists from the value before it is passed to the SP? Can the removal be handled in the cmd. statement in the code behind?

SqlConnection con3 = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString3"].ConnectionString);
SqlCommand cmd3 = new SqlCommand("AdminStoresStudiosLinkSubmit", con3);
cmd3.CommandType = CommandType.StoredProcedure;
cmd3.Parameters.AddWithValue("@.SL_Name", L_Name);
cmd3.Parameters.AddWithValue("@.L_URL", L_URL);

L_URL =http://www.homepage.com and want onlywww.homepage.com to be passed into database.

Thank you,

Use the Replace command e.g. L_URL.Replace("http://", "")

|||

How would that be embedded in -cmd3.Parameters.AddWithValue("@.SL_URL", SL_URL);

thank you

|||

Below is how I initially assign the parameter value. How would I Replace the http:// at this stage?

string SL_URL = tbx_SL_URL.Text;

|||I see it now - different from classic asp -

string L_URL = tbxL_URL.Text;

L_URL = L_URL.Replace("http://","");

thank you

|||

Consider that a URL may begin with other schemes. So, is it good enough to just replacehttp:// or do you needhttps:// andftp:// andssh:// etc... ? If so, you'll want to remove*:// which could be done with well crafted regular expression (in your favorite .Net language of choice).