Showing posts with label parameter. Show all posts
Showing posts with label parameter. Show all posts

Sunday, March 25, 2012

Altering (or recreating) a Stored Procedure "header"

We are using SQL Server 2005 to develop a simple SP. We started by including an output parameter which would report back the identity of the record being inserted or updated. We have since been trying to drop and recreate the SP without the output parameter, or alter the SP with the same outcome in mind. Neither has been succeeding, as confirmed by inspection of the sys.objects and sys.parameters tables. What might we be missing? We are using the Developer Edition, which may or may not be adequate to the task. Or maybe earlier versions of SQL Server are more robust and would be more successful to help us succeed? Please advise. Thank you.Could you please explain how you are recreating the SP? If you are doing it from the UI or something then you may want to post this question in the Tools forum. Otherwise, please post the DDL statement(s) and the reprot steps.|||I believe I see what we were (or in this case weren't) doing... The USE statement is necessary to point the scripts to the correct database. We were seeing the outcome of confusing the master database with our application database. Thanks much for anyone stopping to consider our "dilemma".|||In essence, we are checking for existence of the stored procedure in the system table first, I believe sys.objects. If we find it there first, we drop it. Then we follow up by recreating it. But, as I mentioned in a follow up to our original post, the issue turned out to be a case of not using the USE statement. So what I thought was showing up in our application database was actually showing up in the master database. Not quite what we were shooting for. So hence the confusion.

Monday, March 19, 2012

Alter Table Add field via JDBC, preparedStatement and Parameter fa

I want to add a field to an existing MS-SQL-2000-table via Microsoft-JDBC-SP3-driver, Version 2.2.0040.
I tried to do this with a preparedStatement object for alter table in Java and wanted to pass the fieldname and fieldtype via Parameter. Then I get the message: cannot find the datatype @.P2 (which seems to be the internal placeholder for params). What is
the mistake or is it not possible to use the alter table command with prepared statement and parameters ?
Would be great, if someone knows something about it.
Here is something of the non working code:
PreparedStatement pstmtM1;
String sqlParamM1 = "ALTER TABLE LIMESTAB ADD [ ? ] [ ? ]";
...
pstmtM1 = conM.prepareStatement(sqlParamM1);
pstmtM1.setString (1, "orderno");
pstmtM1.setString(2,"varchar");
pstmtM1.executeUpdate();
Thank's !!
| Thread-Topic: Alter Table Add field via JDBC, preparedStatement and
Parameter fa
| thread-index: AcR0xrMPXWJxd53zRn66DN+jgi9f0g==
| X-WBNR-Posting-Host: 217.146.157.251
| From: "=?Utf-8?B?ZGJpbmZvcm1hdA==?="
<dbinformat@.discussions.microsoft.com>
| Subject: Alter Table Add field via JDBC, preparedStatement and Parameter
fa
| Date: Wed, 28 Jul 2004 10:17:02 -0700
| Lines: 15
| Message-ID: <19D18530-C3A9-4BFE-82C3-B742C37ED580@.microsoft.com>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="Utf-8"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Content-Class: urn:content-classes:message
| Importance: normal
| Priority: normal
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| Newsgroups: microsoft.public.sqlserver.jdbcdriver
| NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.1.29
| Path: cpmsftngxa10.phx.gbl!TK2MSFTNGXA03.phx.gbl
| Xref: cpmsftngxa10.phx.gbl microsoft.public.sqlserver.jdbcdriver:6211
| X-Tomcat-NG: microsoft.public.sqlserver.jdbcdriver
|
| I want to add a field to an existing MS-SQL-2000-table via
Microsoft-JDBC-SP3-driver, Version 2.2.0040.
| I tried to do this with a preparedStatement object for alter table in
Java and wanted to pass the fieldname and fieldtype via Parameter. Then I
get the message: cannot find the datatype @.P2 (which seems to be the
internal placeholder for params). What is the mistake or is it not possible
to use the alter table command with prepared statement and parameters ?
| Would be great, if someone knows something about it.
| Here is something of the non working code:
|
| PreparedStatement pstmtM1;
| String sqlParamM1 = "ALTER TABLE LIMESTAB ADD [ ? ] [ ? ]";
| ...
| pstmtM1 = conM.prepareStatement(sqlParamM1);
| pstmtM1.setString (1, "orderno");
| pstmtM1.setString(2,"varchar");
| pstmtM1.executeUpdate();
|
| Thank's !!
|
|
Hi,
You cannot submit an ALTER TABLE statement using parameters like this.
Below is how SQL Server is interpreting your code:
exec sp_executesql N'ALTER TABLE LIMESTAB ADD [ @.P1 ] [ @.P2 ]', N'@.P1
nvarchar(4000) ,@.P2 nvarchar(4000) ', N'orderno', N'varchar'
Even in straight T-SQL, you must dynamically build the query string and
then execute it using either sp_executesql or EXECUTE. Since you are using
Java, you should just build your string in the code and then execute it
using a standard Statement object:
Statement stmt = conn.createStatement();
String colname = "orderno";
String coltype = "varchar";
String sql = "ALTER TABLE LIMESTAB ADD ";
stmt.executeUpdate(sql + " " + colname + " " + coltype);
Carb Simien, MCSE MCDBA MCAD
Microsoft Developer Support - Web Data
Please reply only to the newsgroups.
This posting is provided "AS IS" with no warranties, and confers no rights.
Are you secure? For information about the Strategic Technology Protection
Program and to order your FREE Security Tool Kit, please visit
http://www.microsoft.com/security.

Friday, February 24, 2012

allows blank value for integer Parameter

Hi have a problem to solve and I hope that this is not a SSRS Bug.

I created a Reports(using SQL Server Project) which has several parameters which values are passed to a SP.

One of these parameter is an Integer and it is an optional value, so if the user fill it is used by the SP, otherwise the SP uses NULL and run anyway.

I starts to define tha parameter:

Datatype = integer

Allow blank value

Available: Non queried

Default: Null

if I want to Preview the report I have to provide an integer to the parameter's field ...

If for instance I set:

Default: Not queried = 0

In the moment I deploy and I use the ReportViewer in my window application the parameter's field is unabled!!

So I tried this solution:

Datatype = integer

Allow blank value

Allow null value

Available: Non queried

Default: Null

In the preview the checkbox: NULL is checked and I click on the View Report.

But when I deploy it,in the ReportViewer in my window application the parameter's field this checkbox is unchecked.

Do I forget something during my setting?I have to control it programmatically?

N.B. By default the user will not user this parameter so the best is that he can click directly on "View Report" without any additional "work" on the parameter!!

Thank you for any help!

hi,

On the report parameters form do this please:

Add a parameter, name it to something,

choose data type integer,

mask as checked the "Allow null value",

select null as default value.

It was working on that way on my box as you wished. I'm using SSRS 2005 wih SP2

Regards,

Janos

Thursday, February 16, 2012

'Allow null values' causes report to run automatically

Hi
I have a long running report. The report is based on a SQL Server 2005
stored procedure, with a single Integer parameter. I want to allow the
user to choose NULL for the parameter, but I don't want the report to
run without the user clicking 'View Report'. But I am finding (from
Report Parameters) when I choose 'Allow null values' there is no
default value of 'None'. I don't want to specify a default value,
because this causes the report to execute immediately.
Has anybody come across this?
cheers,
TJWhat you need, and what would be nice, is a default option of None
(not Null) which doesn't allow the report to run until the user
selects a value. Unfortunatley, the only default options you have
are: Non-queried, From query and Null.
The simplest solution is probably to set a Non-queried default value
that is invalid in your report. This will till cause your report to
run but will return an empty result set. If it's a very simple report
you could then set the visibility of your elements to not show, or
possibly show "Please select a value", if this default invalid value
is given. Otherwise you'll get an empty looking report or, worse yet,
an error; either result would probably be confusing to the user.
Matt Penner
On Jan 2, 7:28 pm, TJ <newsgroups...@.gmail.com> wrote:
> Hi
> I have a long running report. The report is based on a SQL Server 2005
> stored procedure, with a single Integer parameter. I want to allow the
> user to choose NULL for the parameter, but I don't want the report to
> run without the user clicking 'View Report'. But I am finding (from
> Report Parameters) when I choose 'Allow null values' there is no
> default value of 'None'. I don't want to specify a default value,
> because this causes the report to execute immediately.
> Has anybody come across this?
> cheers,
> TJ

Allow null value option in Report Parameters

Hi,
I have very simple parameter driven report that accepts a null value.
When I enable "Allow null value" option under VisualStudio's Report Parameter, the null checkbox is checked by default when I run the report.
Is there anyway that I can uncheck the null check box by default via Visual Studio?
I know I can disable this from Report Property -> Parameter -> Has Default in Report Manager, but I would really like to do this from Visual Studio.
Thank you!You would need to provide a non-null default value for the parameter.
--
This post is provided 'AS IS' with no warranties, and confers no rights. All
rights reserved. Some assembly required. Batteries not included. Your
mileage may vary. Objects in mirror may be closer than they appear. No user
serviceable parts inside. Opening cover voids warranty. Keep out of reach of
children under 3.
"thepacket" <thepacket@.discussions.microsoft.com> wrote in message
news:06A83613-51EF-4A1A-B23F-61AF592AFC81@.microsoft.com...
> Hi,
> I have very simple parameter driven report that accepts a null value.
> When I enable "Allow null value" option under VisualStudio's Report
Parameter, the null checkbox is checked by default when I run the report.
> Is there anyway that I can uncheck the null check box by default via
Visual Studio?
> I know I can disable this from Report Property -> Parameter -> Has Default
in Report Manager, but I would really like to do this from Visual Studio.
> Thank you!
>

Allow null value in multi-value parameter

Hello,

I have a multi-value parameter field and each item comes from a table in the DB.

This multi-value parameter allows to select all or some of the items.

What if I don't want to select ANY item?

I read in the forum the several tray to do the same but the answers are not so clear..

If I say that at the end is a bug in SSRS... AM I right?

Thank you

Marina B.

I do this all the time. THe difference between what you have read and tried and what I am doing is that I am constructing the query as a string, not trying to pass the parameter values to a sproc or anything.

If you are interested in doing it this way, I think I wrote some instructions in other threads... try this one http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1705421&SiteID=1

As to whether it is a "bug in SSRS", I'm not sure why you think that but I'm sure other people will be happy to debate it with you <g>.

>L<

allow null on a multi value parameter

Hi,
I don't seem to be able to set "allow null" on a multi value parameter.
I have this parameter with default values from a stored procedure, I want
the report to be able to generate without having something selected from the
multi value parameter. How is this possible?
Bjorn.multi value parameter does not allow NULL.
Just add an empty string to your select statement in SP.
Bjorn wrote:
> Hi,
> I don't seem to be able to set "allow null" on a multi value parameter.
> I have this parameter with default values from a stored procedure, I want
> the report to be able to generate without having something selected from the
> multi value parameter. How is this possible?
> Bjorn.

Allow NULL - Skips User Input

Hi All,
I have a report with only one parameter(Date field). It is set to allow null
value.
When I click the report it immediately starts rendering the report instead
of waiting for user input. Is it anyway to make the report to wait for user
input without removing the allow null value?
TIA,
SamuelMy understanding of your questions is that you want the report to only begin
generating after the user selects a parameter value and clicks the View
button.
If all parameters have a default value the report will execute immediately.
This is by design and cannot be modified unless you write own parameter
interface.
The workarounds are
* Do not supply a default value to one or more of parameters.
* Create a dummy report parameter and do not supply it with a default
value.
--
Bruce Johnson [MSFT]
Microsoft SQL Server Reporting Services
This posting is provided "AS IS" with no warranties, and confers no rights.
"Samuel" <samuel@.photoninfotech.com> wrote in message
news:e4$C6aCgEHA.904@.TK2MSFTNGP09.phx.gbl...
> Hi All,
> I have a report with only one parameter(Date field). It is set to allow
null
> value.
> When I click the report it immediately starts rendering the report instead
> of waiting for user input. Is it anyway to make the report to wait for
user
> input without removing the allow null value?
> TIA,
> Samuel
>

Monday, February 13, 2012

Allow Any Date in SP Parameter

I have an SP that includes a date as one of the input parameters. In some
instances I would like to accept any date. Is there a way to set a data
parameter to "any"? I tried playing with '%' but no luck there.
WayneRe-read your question Wayne and see if you understand what you mean.
Isn't "any date" still a date?
Do you mean a default value for a parameter?
"Wayne Wengert" <wayneDONTWANTSPAM@.wengert.com> wrote in message
news:u2l$$epEFHA.1408@.TK2MSFTNGP10.phx.gbl...
> I have an SP that includes a date as one of the input parameters. In some
> instances I would like to accept any date. Is there a way to set a data
> parameter to "any"? I tried playing with '%' but no luck there.
> Wayne
>|||Hi,
You should put NULL as input parameter and check it inside your statment
Ex. WHERE data1 = COALESCE(@.data, data1)
"Wayne Wengert" wrote:

> I have an SP that includes a date as one of the input parameters. In some
> instances I would like to accept any date. Is there a way to set a data
> parameter to "any"? I tried playing with '%' but no luck there.
> Wayne
>
>|||On Mon, 14 Feb 2005 06:18:47 -0700, Wayne Wengert wrote:

>I have an SP that includes a date as one of the input parameters. In some
>instances I would like to accept any date. Is there a way to set a data
>parameter to "any"? I tried playing with '%' but no luck there.
Hi Wayne,
Maybe this web site has some useful idea for you:
http://www.sommarskog.se/dyn-search.html
Best, Hugo
--
(Remove _NO_ and _SPAM_ to get my e-mail address)|||Sorry I wasn't clear...
I want the query inside the SP, which uses that data parameter value as one
of the "WHERE" clauses, to accept all records, no matter what date is in the
record. For example, if the Select statement inside the SP is something
like...
SELECT CustomerID, CustomerName FROM Customers WHERE PurchaseDate =
@.dateparameter
I suspect I'll need to use some dummy date like '1/1/1900' and when the date
parameter has that value, just leave that part of the WHERE clause out.
Wayne
"raydan" <rdanjou@.savantsoftNOSPAM.com> wrote in message
news:%23BF3UqpEFHA.3244@.TK2MSFTNGP15.phx.gbl...
> Re-read your question Wayne and see if you understand what you mean.
> Isn't "any date" still a date?
> Do you mean a default value for a parameter?
> "Wayne Wengert" <wayneDONTWANTSPAM@.wengert.com> wrote in message
> news:u2l$$epEFHA.1408@.TK2MSFTNGP10.phx.gbl...
some
>|||Thanks - that is probably what I'll do
Wayne
"Tomasz Borawski" <TomaszBorawski@.discussions.microsoft.com> wrote in
message news:24CE82C5-2B9A-4B61-BF91-C7E2F21B232D@.microsoft.com...
> Hi,
> You should put NULL as input parameter and check it inside your statment
> Ex. WHERE data1 = COALESCE(@.data, data1)
> "Wayne Wengert" wrote:
>
some|||Very nice resource - thanks
Wayne
"Hugo Kornelis" <hugo@.pe_NO_rFact.in_SPAM_fo> wrote in message
news:9sa111datfaa5r7g45p8ft0blhmg6amune@.
4ax.com...
> On Mon, 14 Feb 2005 06:18:47 -0700, Wayne Wengert wrote:
>
> Hi Wayne,
> Maybe this web site has some useful idea for you:
> http://www.sommarskog.se/dyn-search.html
> Best, Hugo
> --
> (Remove _NO_ and _SPAM_ to get my e-mail address)

Sunday, February 12, 2012

'ALL' parameter when using MDX query

Is there a way to include an 'ALL' option for a parameter when the data for
the parameter selection is retrieved using an MDX statement? Is there an MDX
function/technique similar to the UNION function in SQL to allow additional
values to be added to the list of values?
Thanks,
PDtry this and modify to suit your needs:
WITH
Member[All Dimension Level].[All Dimension Levels Individually] as '[All
Dimension Levels Individually]'
Member [Measures].[MemberUniqueName] as '[Dimension].currentmember.UniqueName'
Member [Measures].[MemberDisplayName] as
'Space([Dimension].Currentmember.Level.Ordinal * 4) +
[Dimension].Currentmember.Name'
SELECT
{[Measures].[MemberUniqueName],[Measures].[MemberDisplayName]} on Columns,
{
[All Dimension Level].[All Dimension Levels Individually],
[Dimension].Members} on rows
from [YourCube]
"PD" wrote:
> Is there a way to include an 'ALL' option for a parameter when the data for
> the parameter selection is retrieved using an MDX statement? Is there an MDX
> function/technique similar to the UNION function in SQL to allow additional
> values to be added to the list of values?
> Thanks,
> PD|||Thanks for the reply Mike. I should have mentioned in my original post, that
the objective is to list EACH of the retrieved members for the dimension on
separate pages of the report. So if the dimension has 5 members, there would
be 5 pages in the report if the user selected the 'All' option for the
parameter. Does your example retrieve each of the members for the dimension
or the 'All' (total) member for the dimension?
Thanks,
PD
"mike" wrote:
> try this and modify to suit your needs:
> WITH
> Member[All Dimension Level].[All Dimension Levels Individually] as '[All
> Dimension Levels Individually]'
> Member [Measures].[MemberUniqueName] as '[Dimension].currentmember.UniqueName'
> Member [Measures].[MemberDisplayName] as
> 'Space([Dimension].Currentmember.Level.Ordinal * 4) +
> [Dimension].Currentmember.Name'
> SELECT
> {[Measures].[MemberUniqueName],[Measures].[MemberDisplayName]} on Columns,
> {
> [All Dimension Level].[All Dimension Levels Individually],
> [Dimension].Members} on rows
> from [YourCube]
> "PD" wrote:
> > Is there a way to include an 'ALL' option for a parameter when the data for
> > the parameter selection is retrieved using an MDX statement? Is there an MDX
> > function/technique similar to the UNION function in SQL to allow additional
> > values to be added to the list of values?
> > Thanks,
> > PD|||if you run my example with your modifications on one of your dimensions,
you'll see that your parm list would have :
member name all individually ( so that you know you need all members )
All Members ( the all level of your dimension )
each unique member ( so a user can select just 1 member )
in reporting services just set for a new page on each member. you should
find this in the property pages of the table, list, etc of what your using in
your report.
"PD" wrote:
> Thanks for the reply Mike. I should have mentioned in my original post, that
> the objective is to list EACH of the retrieved members for the dimension on
> separate pages of the report. So if the dimension has 5 members, there would
> be 5 pages in the report if the user selected the 'All' option for the
> parameter. Does your example retrieve each of the members for the dimension
> or the 'All' (total) member for the dimension?
> Thanks,
> PD
> "mike" wrote:
> > try this and modify to suit your needs:
> >
> > WITH
> > Member[All Dimension Level].[All Dimension Levels Individually] as '[All
> > Dimension Levels Individually]'
> > Member [Measures].[MemberUniqueName] as '[Dimension].currentmember.UniqueName'
> > Member [Measures].[MemberDisplayName] as
> > 'Space([Dimension].Currentmember.Level.Ordinal * 4) +
> > [Dimension].Currentmember.Name'
> >
> > SELECT
> > {[Measures].[MemberUniqueName],[Measures].[MemberDisplayName]} on Columns,
> > {
> > [All Dimension Level].[All Dimension Levels Individually],
> > [Dimension].Members} on rows
> > from [YourCube]
> >
> > "PD" wrote:
> >
> > > Is there a way to include an 'ALL' option for a parameter when the data for
> > > the parameter selection is retrieved using an MDX statement? Is there an MDX
> > > function/technique similar to the UNION function in SQL to allow additional
> > > values to be added to the list of values?
> > > Thanks,
> > > PD