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

Thursday, March 29, 2012

Creating an All option for parameter value in GUID format

I am working with SRS 2005 SP1 which no longer has the "ALL" option available on parameters. I am trying to create an "ALL" entry in a picklist so it can be used in a where clause for a dataset. I have a dataset with a union statement that creates a list of CRM usersids and names and an entry with a dummy guid with the name "All". Parameter is defined as a string type, with a dataset providing a list of users (label field) and their corresponding GUID value (value field), along with the an "All" entry.

select systemuserid, fullname
from FilteredSystemUser
Union
Select '00000000-0000-0000-0000-000000000000' as systemuserid, ' All' as fullname
order by fullname

The issue I am running into is implementing logic in another dataset referencing my parameter.

All is fine in the where clause if it is structured "where ownerid in (@.Users)" but if I try to add logic to check for the "All" option "where (ownerid in (@.Users) or @.Users = '00000000-0000-0000-0000-000000000000') it errors out.

How do you impement "All" when you're dealing with a GUID type field? Thanks.

Have you looked at SSRS SP2? It puts the Select All option back. You can get it HERE

R

|||Thanks. We will be installing SP2.

Creating an "ALL" Parameter Value

I am trying to create an "All" parameter. I created a stored procedure that says:

Code Snippet

CREATE PROCEDURE dbo.Testing123

AS


SELECT distinct ID AS ID, ID AS Label

FROM TPFDD


UNION

SELECT NULL AS ID, 'ALL' AS Label

FROM TPFDD
Order by ID
GO

Then I createded a report parameter and set the default to All

I also created a filter that sets the textbox vaule to the report parameter.

In theory I think that when I select ALL it should bring back everything but it is not. It brings back nothing. What am i doing wrong?


In the query that returns the data for the report, I suspect you're doing something like:

WHERE id = @.ID

What you would need to do is:

WHERE id = @.ID OR @.ID IS NULL

I think that you should be setting your default value to NULL instead of "ALL", that would remove the need for your filter.

|||

Is this what you mean?

Code Snippet

CREATE PROCEDURE dbo.Testing123

@.id char

AS


SELECT distinct ID AS ID, ID AS Label

FROM TPFDD


UNION

SELECT NULL AS ID, 'ALL' AS Label

FROM TPFDD

Where ID = @.id or @.id is NULL

Order by ID

Should this make it work?

I am also getting this error: "The report parameter 'pid' has a DefaultValue or ValidValue that depends on the report parameter "pid" Forward dependencies are not valid."

|||

No, I meant for you to put it in the query that is returning the data for your report, not for the parameter.

I am assuming that what you have currently is a parameter as a drop down box where they select the id from the list generated by the query that you have posted above. Then, the user presses "view Report" and a report for that id is executed with data filled in by some other query, that currently has

Where ID = @.id

to return just the data for the id you have selected.

If you add

or @.id is NULL

to the where clause, it will detect if the user has selected ALL and not filter the results.

Maybe I have misunderstood what you're trying to do?

|||You were right! Thank you so much for your help with this

Thursday, March 22, 2012

Creating a table from .NET

I need to create tables from a C# code. I made a stored procedure hoping that I will pass a table name as a parameter: @.tabName. The procedure executed in SqlServer All Right but when I called it from C# code it created not the table I put in as a parameter but table "tabName." Otherwise everything else was perfect: coumns, etc.

Here is my stored procedure.

set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[CreateTableTick]
@.tabName varchar(24) = 0
AS
BEGIN
SET NOCOUNT ON;
CREATE TABLE tabName
(
bid float NULL,
ask float NULL,
last float NULL,
volume float NULL,
dateTimed datetime NULL
)
END

What went wrong?

Thank you.

DECLARE @.SQL VARCHAR(500)

SET @.SQL = 'CREATE TABLE ' + @.TableName + ' (bid float NULL,
ask float NULL,
last float NULL,
volume float NULL,
dateTimed datetime NULL
)'

EXEC @.Sql

-- It should be noted that you SHOULD SANITIZE your parameter and make sure that a user does not put anything non-alphanumeric and _ because a malicious user could potentially execute an sql injection if you did not.

If you search for sp_execsql I believe you will find tons of postings.

|||

To be honest, I wouldn't expect the SProc you've listed to work the way you've described in SQL Server either. What you're looking for is dynamic SQL, which has been discussed a number of times in the past weeks in this forum. I suggest you read the information at http://www.sommarskog.se/dynamic_sql.html before you proceed to ensure that you understand the security implications of using SPs with dynamic SQL before implement it.

If the possibility of SQL Injection is not an issue for you, or you've figure out how to mediate it, that same document also has some recomendations on possible implementations.

Mike

|||Thank you both, marcD and Mike.|||Hi,

you should better use the SMO classes which expose an interface (.NET API) for a developer to manage SQL Server objects. You don′t need to care about syntax or semantics, as SMO is object oriented and can be easily used within C# and Visual Studio (with Intellisense) to produce a SQL-injectionfree code (if used the right way :-) ) The API is the successor of the DMO classes, formerly used in SQL Server 2000 and below.

HTH, Jens K. Suessmeyer.

http://www.sqlserver2005.de

Creating a suscription on a parameterized report

I have a report that I just created that has a month and year parameter.
this report is needed at the first of every month to show the activity of
previous month. I would like to create a subscription that executes this
report automatically. Can I set up reporting services to automatically run
the subscription based on the previous month and year each first of the
month?This can be achieved by setting the parameters non-queried default values to
something liek this
=Today.AddMonths(-1)
This will grab todays date (execution date) and add a negative month. you
can do AddDays and AddYears...
for the start date and
"Aaronous" <aaronous@.hotmail.com> wrote in message
news:%230afyX%23DFHA.3928@.TK2MSFTNGP15.phx.gbl...
>I have a report that I just created that has a month and year parameter.
>this report is needed at the first of every month to show the activity of
>previous month. I would like to create a subscription that executes this
>report automatically. Can I set up reporting services to automatically run
>the subscription based on the previous month and year each first of the
>month?
>|||I have been using:
=Today.AddDays(-1)
The result is on the first day of the month, the default parameter is the
previous month. After that, it uses the current month. When I first started
doing this, I used iif(Day(Today()=1) & Hour(Now())<6, Today.AddDays(-1),
Today()). This assumed that the monthly subscriptions ran before 6am on the
1st of the month. I now assume that if somebody wants to look at a monthly
report on the 1st, they really want to see the last month.
"Joseph Scalise" wrote:
> This can be achieved by setting the parameters non-queried default values to
> something liek this
> =Today.AddMonths(-1)
> This will grab todays date (execution date) and add a negative month. you
> can do AddDays and AddYears...
> for the start date and
> "Aaronous" <aaronous@.hotmail.com> wrote in message
> news:%230afyX%23DFHA.3928@.TK2MSFTNGP15.phx.gbl...
> >I have a report that I just created that has a month and year parameter.
> >this report is needed at the first of every month to show the activity of
> >previous month. I would like to create a subscription that executes this
> >report automatically. Can I set up reporting services to automatically run
> >the subscription based on the previous month and year each first of the
> >month?
> >
>
>

Wednesday, March 21, 2012

Creating a stored procedure

Im trying to create a stored procedure that selects everything from a
function name that im passing in through a parameter..

create procedure SP_selectall
(@.functionname varchar(25))
as

select * from @.functioname

go

I keep getting this error:

Server: Msg 137, Level 15, State 2, Procedure SP_selectall, Line 5
Must declare the variable '@.functioname'.

Whats the issue?"Jim" <jim.ferris@.motorola.com> wrote in message
news:729757f9.0311241229.a3a2cff@.posting.google.co m...
> Im trying to create a stored procedure that selects everything from a
> function name that im passing in through a parameter..
> create procedure SP_selectall
> (@.functionname varchar(25))
> as
> select * from @.functioname
> go
>
> I keep getting this error:
> Server: Msg 137, Level 15, State 2, Procedure SP_selectall, Line 5
> Must declare the variable '@.functioname'.
> Whats the issue?

You could do this with dynamic SQL (see below), but that's probably not a
good idea. What happens if some functions require parameters and some don't?
If you don't know the function name ahead of time, then you don't know the
form of the result set, so you may have difficulties handling it on the
client side. Performance could be a problem too, if any of the functions are
complex. For a detailed discussion of dynamic SQL, see here:

http://www.algonet.se/~sommar/dynamic_sql.html

But having said all that, if you have a good reason, and if you're
completely sure that you will never write a function requiring parameters,
then this should work:

create proc dbo.SelectAllFromFunction
@.FunctionName sysname
as
set nocount on
begin
exec('select * from dbo.' + @.FunctionName + '()')
end

This is for table-valued functions only, of course. You shouldn't use sp_ as
the prefix for your stored procs, by the way - that's used for system procs,
and the name resolution is different for them.

Simon

creating a stored procedure

hi,
can we use table as an out parameter in sql stored procedure?
if so can any one help me out with an example.
thanks in advance
regards,
ThamaraiThis seem to be what you are locking for: http://www.sommarskog.se/share_data.html

Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
<thamarai.82@.gmail.com> wrote in message
news:1157544749.151831.33840@.h48g2000cwc.googlegroups.com...
> hi,
> can we use table as an out parameter in sql stored procedure?
> if so can any one help me out with an example.
> thanks in advance
> regards,
> Thamarai
>|||thamarai.82@.gmail.com wrote:
> hi,
> can we use table as an out parameter in sql stored procedure?
> if so can any one help me out with an example.
> thanks in advance
> regards,
> Thamarai
>
Look up "CREATE PROCEDURE" in Books Online... You'll find the answer is
no...
Tracy McKibben
MCDBA
http://www.realsqlguy.com|||Hi,
Can you please explain a bit more about your requirement? Incase if you want
to return a table as a result set then take a look into
URL from Tibors post.
Thanks
Hari
SQL Server MVP
<thamarai.82@.gmail.com> wrote in message
news:1157544749.151831.33840@.h48g2000cwc.googlegroups.com...
> hi,
> can we use table as an out parameter in sql stored procedure?
> if so can any one help me out with an example.
> thanks in advance
> regards,
> Thamarai
>|||The answer is No. But even if you could have a table datatype as an OUTPUT
parameter, what would you catch that with in the application? Does the
application provide a table datatype for a variable?
A Stored Procedure and provide a resultset, which the application can
capture as a table in a dataset. (Look up the use of the dataadapter
object.)
Arnie Rowland, Ph.D.
Westwood Consulting, Inc
Most good judgment comes from experience.
Most experience comes from bad judgment.
- Anonymous
<thamarai.82@.gmail.com> wrote in message
news:1157544749.151831.33840@.h48g2000cwc.googlegroups.com...
> hi,
> can we use table as an out parameter in sql stored procedure?
> if so can any one help me out with an example.
> thanks in advance
> regards,
> Thamarai
>

Creating a Stored Procedure

Is it possible to create a stored procedure that execute a delete command from a table whose name is specified as a parameter of the stored procedure?

Thank you

Yes. You would need to use dynamic SQL for that.

CREATE PROC....@.tblvarchar(25)AS...Declare @.sqlvarchar(100)--Build your SQLSET @.sql ='DELETE FROM ' + @.tbl +' WHERE <condition>'--Execute your SQLEXEC(@.sql)-- You can also use sp_ExecuteSQL. Check out BOL for more info.

|||

A problem with dynamic SQL though, is that by default the caller has to have delete permissions on the table. Will all callers have that permission? That could be a significant vulnerability in your application and database server.

What version of SQL Server are you using? If it's 2005, you could use the EXECUTE AS option in the stored procedure to run with another principal's permissions. That could go a long way towards making this more secure.

Don

|||

Thank you for the info.

A valuable one.

creating a stored procedure

hi,
can we use table as an out parameter in sql stored procedure?
if so can any one help me out with an example.
thanks in advance
regards,
ThamaraiThis seem to be what you are locking for: http://www.sommarskog.se/share_data.html
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
<thamarai.82@.gmail.com> wrote in message
news:1157544749.151831.33840@.h48g2000cwc.googlegroups.com...
> hi,
> can we use table as an out parameter in sql stored procedure?
> if so can any one help me out with an example.
> thanks in advance
> regards,
> Thamarai
>|||thamarai.82@.gmail.com wrote:
> hi,
> can we use table as an out parameter in sql stored procedure?
> if so can any one help me out with an example.
> thanks in advance
> regards,
> Thamarai
>
Look up "CREATE PROCEDURE" in Books Online... You'll find the answer is
no...
Tracy McKibben
MCDBA
http://www.realsqlguy.com|||Hi,
Can you please explain a bit more about your requirement? Incase if you want
to return a table as a result set then take a look into
URL from Tibors post.
Thanks
Hari
SQL Server MVP
<thamarai.82@.gmail.com> wrote in message
news:1157544749.151831.33840@.h48g2000cwc.googlegroups.com...
> hi,
> can we use table as an out parameter in sql stored procedure?
> if so can any one help me out with an example.
> thanks in advance
> regards,
> Thamarai
>|||The answer is No. But even if you could have a table datatype as an OUTPUT
parameter, what would you catch that with in the application? Does the
application provide a table datatype for a variable?
A Stored Procedure and provide a resultset, which the application can
capture as a table in a dataset. (Look up the use of the dataadapter
object.)
--
Arnie Rowland, Ph.D.
Westwood Consulting, Inc
Most good judgment comes from experience.
Most experience comes from bad judgment.
- Anonymous
<thamarai.82@.gmail.com> wrote in message
news:1157544749.151831.33840@.h48g2000cwc.googlegroups.com...
> hi,
> can we use table as an out parameter in sql stored procedure?
> if so can any one help me out with an example.
> thanks in advance
> regards,
> Thamarai
>

Creating a store procedure with output parameter

Hi all,
Could someone give me an example on how to create and execute the store procedure with using output parameter?
In normal, I create the store procedure without using output parameter, and I did it as follow:
CREATE PROC NewEmployee
(ID int(9), Name Varchar (30), hiredate DateTime, etc...)
AS
BEGIN
//my code
END
GO
When i executed it, I would said: Execute NewEmployee 123456789, 'peter mailler', getDate(), etc...
For output parameter:
CREATE PROC NewEmployee
(ID int(9), Name Varchar (30), hiredate DateTime,@.message Varchar(40) out)
AS
BEGIN
insert into Employee .....
//if error encountered
set@.message = "Insertion failure"
END
GO
Exec NewEmployee 123456789, 'peter mailler', getDate(),do I need to input something for the output parameter here?

Anyone could give me an example on how to handle the output parameter within the store procedure coz I am not sure how to handle it?
Many thanks.



Hi,

when calling EXEC newEmployee... you need ti declarare a parameter, assign it to the call and then you'd get the output value from it.

DECLARE @.msg nvarchar(40);
Exec NewEmployee 123456789, 'peter mailler', getDate(),@.msg;

-- Here you could access @.msg to get what was outputted

creating a SP that add columns into a table

Hi all,

i want to create a stored procedure that will add columns into a table but i have a problem using a parameter in this context, for example:

- SP --

-- PARAMS --

declare @.TableName nvarchar(30)

declare @.colName nvarchar(30)

declare @.colType nvarChar(30)

-- Actual Code

alter table @.TableName

add @.colName @.colType

it looks as though the paramater cannot be used in this context or i should do something in order to make sense of this code.. please help me :)

Z

You have to use Dynamic SQL here..

- SP --

-- PARAMS --

declare @.TableName nvarchar(30)

declare @.colName nvarchar(30)

declare @.colType nvarChar(30)

-- Actual Code

Declare @.SQL as Varchar(1000);

Select @.SQL = 'alter table ' + @.TableName + ' add ' + @.colName + ' ' + @.colType

Exec (@.SQL)

|||

Hi Zacky,

Here is a possible solution:

create procedure AddColumnToTable
(
@.tableName varchar(50),
@.columnName varchar(50),
@.dataType varchar(50)
)
as
begin
declare @.sql varchar(4000)
set @.sql = 'ALTER TABLE ' + @.tableName + ' ADD ' + @.columnName + ' ' + @.dataType
exec sp_sqlexec @.sql
end

Greetz,

Geert

Geert Verhoeven
Consultant @. Ausy Belgium

My Personal Blog

|||

Sorry MandiD, I didn't see that you posted an answer while I was creating mine.

|||

What kind of error you are getting here..

R u missed any code ..reposting the code again

Begin
declare @.TableName nvarchar(30)
declare @.colName nvarchar(30)
declare @.colType nvarChar(30)
declare @.SQL as NVarchar(1000);
-- Actual Code
--Select @.TableName='Sample', @.colName='newCol1', @.colType='Int'

Select @.SQL = N'alter table ' + @.TableName + ' add ' + @.colName + ' ' + @.colType
Exec (@.SQL)
--or use
--Exec sp_executesql @.SQL
End

|||

thanks looks great!!

Z

Wednesday, March 7, 2012

Creating a filter on a Dataset

Can I create a report parameter label list to only show the values
that have been extracted wthin a field in my dataset?
i.e. in the same way you add an autofilter on a column in excel, to
return the values in that column.You would need to have a second dataset. Make it exactly the same except use
the distinct and just the single field you care about.
Of course if you are doing this, then your main dataset should take this and
use it as a query parameter so return as little data as possible. Stay away
from filters as much as possible.
Bruce Loehle-Conger
MVP SQL Server Reporting Services
"Andy" <andywilliams1971@.msn.com> wrote in message
news:17287b26-fbc2-4442-a6f2-ba6cfdd83718@.u10g2000prn.googlegroups.com...
> Can I create a report parameter label list to only show the values
> that have been extracted wthin a field in my dataset?
> i.e. in the same way you add an autofilter on a column in excel, to
> return the values in that column.

Creating a Dynamic Temporary Table

When I execute the following Stored Procedure with a parameter (EXEC MyProc
'MyTab'); it creates a table ##MyTempTable. What happened to the parameter
@.MyTempTable that was passed in the SQL statement?
I meant to create the temp table named MyTab as passed to the SP from the
statement.
CREATE PROCEDURE [dbo].[MyProc] (@.MyTempTable nvarchar(50)) AS
SELECT *
INTO ##MyTempTable
FROM Customers
GOThe right answer is never pass a table name as a parameter. You need
to understand the basic idea of a data model and what a table means in
implementing a data model. Go back to basics. What is a table? A
model of a set of entities or relationships. EACH TABLE SHOULD BE A
DIFFERENT KIND OF ENTITY. What having a generic procedure works
equally on automobiles, octopi or Britney Spear's discology is saying
that your application is a disaster of design.
1) This is dangerous because some user can insert pretty much whatever
they wish -- consider the string 'Foobar; DELETE FROM Foobar; SELECT *
FROM Floob' in your statement string.
2) It says that you have no idea what you are doing, so you are giving
control of the application to any user, present or future. Remember
the basics of Software Engineering? Modules need weak coupling and
strong cohesion, etc. This is far more fundamental than just SQL; it
has to do with learning to programming at all.
3) If you have tables with the same structure which represent the same
kind of entities, then your schema is not orthogonal. Look up what
Chris Date has to say about this design flaw. Look up the term
attribute splitting.
4) You might have failed to tell the difference between data and
meta-data. The SQL engine has routines for that stuff and applications
do not work at that level, if you want to have any data integrity.
Stop writing code like this. You are mimicking a 1950's scratch tape
file. But more than that, you never used the parameter anywhere in the
procedure -- nothing happened to it. Also, I see you used the
"Magical NVARCHAR(50)" data type. Do you really have names that long?
I doubt it. You will eventually get such a garbage name; I can give
you a Chinese Suttra if you want to do use it :)
Use the Customers table in your statements. Unfortunately, we have no
idea what you wanted to do, so nobody can help you further.|||Shariq,
I have a little confusion as to what you are attempting to achieve.
The short answer to what you asking is as follows:
CREATE STORED PROCEDURE [dbo].[usp_My_SProc]
@.MyTempTable nvarchar(50)=''
AS
If @.MyTempTable<>''
BEGIN
DECLARE @.sSTR varchar(2000)
SET @.sSTR = ' '
SET @.sSTR = @.sSTR + ' SELECT * INTO '
SET @.sSTR = @.sSTR + '#' + @.MyTempTable
SET @.sSTR = @.sSTR + ' FROM Customers '
EXEC (@.sSTR)
END
This will achieve the result your question poses, but does not a lot to
possibly achieve your intended goal.
The one drawback to the above code is that the EXEC(@.sSTR) command runs in
an independant thread from the Stored Procedure and such a table cannot be
accessed from another thread, unless you use the ## prefix, but this, again,
brings up it's own dilemmas as the same Stored Procedure acn only be run onc
e
at a time.
"Shariq" wrote:

> When I execute the following Stored Procedure with a parameter (EXEC MyPro
c
> 'MyTab'); it creates a table ##MyTempTable. What happened to the parameter
> @.MyTempTable that was passed in the SQL statement?
> I meant to create the temp table named MyTab as passed to the SP from the
> statement.
> CREATE PROCEDURE [dbo].[MyProc] (@.MyTempTable nvarchar(50)) AS
> SELECT *
> INTO ##MyTempTable
> FROM Customers
> GO
>|||Tony,
Thanks for you help; the code you provided is exactly what I was looking for
.
"Tony Scott" wrote:
> Shariq,
> I have a little confusion as to what you are attempting to achieve.
> The short answer to what you asking is as follows:
> CREATE STORED PROCEDURE [dbo].[usp_My_SProc]
> @.MyTempTable nvarchar(50)=''
> AS
> If @.MyTempTable<>''
> BEGIN
> DECLARE @.sSTR varchar(2000)
> SET @.sSTR = ' '
> SET @.sSTR = @.sSTR + ' SELECT * INTO '
> SET @.sSTR = @.sSTR + '#' + @.MyTempTable
> SET @.sSTR = @.sSTR + ' FROM Customers '
> EXEC (@.sSTR)
> END
> This will achieve the result your question poses, but does not a lot to
> possibly achieve your intended goal.
> The one drawback to the above code is that the EXEC(@.sSTR) command runs in
> an independant thread from the Stored Procedure and such a table cannot be
> accessed from another thread, unless you use the ## prefix, but this, agai
n,
> brings up it's own dilemmas as the same Stored Procedure acn only be run o
nce
> at a time.
>
> "Shariq" wrote:
>

Saturday, February 25, 2012

Creating a Databse on the Fly

I wanted to Write A Stored Procedure which Will accepts the name of the "Database" as a parameter
But when i am trying to do so i am getting error
--------------------------
create procedure create_DB
@.db_name as varchar(30)
as
create database @.db_name
------------------------
The error is as Follows
'Incorrect syntax near '@.db_name'.'

Pl help me in this regardsOriginally posted by pankaj_bidwai
I wanted to Write A Stored Procedure which Will accepts the name of the "Database" as a parameter
But when i am trying to do so i am getting error
--------------------------
create procedure create_DB
@.db_name as varchar(30)
as
create database @.db_name
------------------------
The error is as Follows
'Incorrect syntax near '@.db_name'.'

Pl help me in this regards

I guess you missed the brackets:

create procedure create_DB
(@.db_name as varchar(30))
as
create database @.db_name|||Hi
No that is not the prob even if i use the brackets i will get an error
If i give harcoded name instead of variable i don't get an error
Originally posted by DoktorBlue
I guess you missed the brackets:

create procedure create_DB
(@.db_name as varchar(30))
as
create database @.db_name|||pankaj_bidwai, CREATE DATABASE does not accept a variable for the db name. Have you tried:

declare @.db_name varchar(30)
set @.db_name = 'PSYTEST'
execute('create database ' + @.db_name)
execute('drop database ' + @.db_name)|||Remove the "AS" in the parameter list in the stored proc signature.|||Hu?? Please post corrected code demonstrating how this works.|||Here you go...

create procedure create_DB
@.db_name varchar(30)
as

exec('create database ' + @.db_name)

go|||What happend to removing the "AS"?|||Alas, that wasn't the problem after all. Using "as" in the parameter list is a technique that I've not seen before. I didn't think it was valid SQL. The real problem was the lack of dynamic SQL to build the CREATE DATABASE statement properly.

I didn't read any of the other threads, so my reply may have been redundant.

Sunday, February 19, 2012

CreateSubscription parameter array problem

I'm using the CreateSubscription method and having a problem with the
parameter values getting rejected. I am wondering if I am experiencing a
type conflict because my report parameters are all integers but from the
samples it looks like I may need to define them as strings. Is there a
limitation on using this web service method that your report parameters must
all be strings?
The error I am getting is not that helpful:
The value of parameter 'Parameters' is not valid. Check the documentation
for information about valid values. --> The value of parameter 'Parameters'
is not valid. Check the documentation for information about valid values.
I am building the parameter array like this:
Dim parameters(4) As ParameterValue
parameters(0) = New ParameterValue()
parameters(0).Name = "PriorMonthEndAsOfDateDimensionId"
parameters(0).Value = "353"
parameters(1) = New ParameterValue()
parameters(1).Name = "MonthEndAsOfDateDimensionId"
parameters(1).Value = "419"
parameters(2) = New ParameterValue()
parameters(2).Name = "StrategyDimensionId"
parameters(2).Value = "98"
parameters(3) = New ParameterValue()
parameters(3).Name = "FundDimensionId"
parameters(3).Value = "847"
I get the same error if I assign the values without the quotes.
Thanks,
SimonI'm an idiot.
I was defining the array incorrectly. When I change it to: Dim
parameters(3) As ParameterValue
it works.
Sorry.
"Simon Schmidt" wrote:
> I'm using the CreateSubscription method and having a problem with the
> parameter values getting rejected. I am wondering if I am experiencing a
> type conflict because my report parameters are all integers but from the
> samples it looks like I may need to define them as strings. Is there a
> limitation on using this web service method that your report parameters must
> all be strings?
> The error I am getting is not that helpful:
> The value of parameter 'Parameters' is not valid. Check the documentation
> for information about valid values. --> The value of parameter 'Parameters'
> is not valid. Check the documentation for information about valid values.
> I am building the parameter array like this:
> Dim parameters(4) As ParameterValue
> parameters(0) = New ParameterValue()
> parameters(0).Name = "PriorMonthEndAsOfDateDimensionId"
> parameters(0).Value = "353"
> parameters(1) = New ParameterValue()
> parameters(1).Name = "MonthEndAsOfDateDimensionId"
> parameters(1).Value = "419"
> parameters(2) = New ParameterValue()
> parameters(2).Name = "StrategyDimensionId"
> parameters(2).Value = "98"
> parameters(3) = New ParameterValue()
> parameters(3).Name = "FundDimensionId"
> parameters(3).Value = "847"
> I get the same error if I assign the values without the quotes.
> Thanks,
> Simon

Tuesday, February 14, 2012

Create view question

I want to create view to join several tables.
As I want to select the data by the date range , Can I pass the date
condition as parameter to it ?
Please tell me how to do .
I never use View before.
Thanks a lot"UDF's in SQL Server 2000 would give you the capability to do what you want
with a parameterized view... table valued UDF's accept parameters and can be
used anyway a table/view can be used..."
But you can use a parameter from your query to query your view (from your
client or from a procedure)
Select * from YourView
Where Yourconditionscolname = @.Somevar
HTH, Jens Suessmeyer.
http://www.sqlserver2005.de
--
"Agnes" <agnes@.dynamictech.com.hk> schrieb im Newsbeitrag
news:%23CjkJamTFHA.3188@.TK2MSFTNGP09.phx.gbl...
>I want to create view to join several tables.
> As I want to select the data by the date range , Can I pass the date
> condition as parameter to it ?
> Please tell me how to do .
> I never use View before.
> Thanks a lot
>|||Thank Jens. However, Select * from YourView
Your view is a view also, How Can I set the parameter during create YourView
'
"Jens Smeyer" <Jens@.Remove_this_For_Contacting.sqlserver2005.de> glsD:OA62IimTF
HA.2128@.TK2MSFTNGP15.phx.gbl...
> "UDF's in SQL Server 2000 would give you the capability to do what you
> want
> with a parameterized view... table valued UDF's accept parameters and can
> be
> used anyway a table/view can be used..."
> But you can use a parameter from your query to query your view (from your
> client or from a procedure)
> Select * from YourView
> Where Yourconditionscolname = @.Somevar
>
> HTH, Jens Suessmeyer.
> --
> http://www.sqlserver2005.de
> --
> "Agnes" <agnes@.dynamictech.com.hk> schrieb im Newsbeitrag
> news:%23CjkJamTFHA.3188@.TK2MSFTNGP09.phx.gbl...
>|||> Your view is a view also, How Can I set the parameter during create YourVi
ew
The short version: You can't short of scripting the entire Create View (and
Drop
View) statement each time you need it (which also means your users will have
to
be granted those rights). The better solution is to use a user-defined funct
ion
instead. This *will* allow you to pass a parameter and add forking condition
s.
HTH
Thomas
"Agnes" <agnes@.dynamictech.com.hk> wrote in message
news:Ozm1xfsTFHA.2768@.tk2msftngp13.phx.gbl...
> Thank Jens. However, Select * from YourView
> Your view is a view also, How Can I set the parameter during create YourVi
ew
> '
> "Jens Smeyer" <Jens@.Remove_this_For_Contacting.sqlserver2005.de>
> glsD:OA62IimTFHA.2128@.TK2MSFTNGP15.phx.gbl...
>|||Hi Agnes
You can do as:
CREATE VIEW <view_name>
AS
SELECT <Fiends>
FROM <Tables>
[WHERE <Conditions>]
to see the result, u can use
SELECT * FROM <view_name>
Please let me know if this answered the problem
thanks and regards
Chandra
"Agnes" wrote:

> I want to create view to join several tables.
> As I want to select the data by the date range , Can I pass the date
> condition as parameter to it ?
> Please tell me how to do .
> I never use View before.
> Thanks a lot
>
>|||No you cant do that while setting up the view the example was some client
code to query the view with conditions
Select * from YourView
Where Yourconditionscolname = [Placeyourvariablehere]
You view Would look like some "normal" select:
SELECT...
FROM
JOIN
ORDER
and so on.
HTH, Jens Suessmeyer.
http://www.sqlserver2005.de
--
"Agnes" <agnes@.dynamictech.com.hk> schrieb im Newsbeitrag
news:Ozm1xfsTFHA.2768@.tk2msftngp13.phx.gbl...
> Thank Jens. However, Select * from YourView
> Your view is a view also, How Can I set the parameter during create
> YourView '
> "Jens Smeyer" <Jens@.Remove_this_For_Contacting.sqlserver2005.de>
> glsD:OA62IimTFHA.2128@.TK2MSFTNGP15.phx.gbl...
>