Showing posts with label create. Show all posts
Showing posts with label create. Show all posts

Thursday, March 29, 2012

Dynamic Security in SSAS 2005

I am trying to create dynamic security and was hoping to use a named query to link the fact table to a dimension that contains Active Directory users and companies - a user can have access to multiple companies. The problem is that I cannot find out how to get the username of the current user.

Anyone have any ideas?

thanks in advance.

Does the standard MDX keyword: UserName return what you want, like:

>>

With member [Measures].[CurrentUser] as UserName

select {[Measures].[CurrentUser]} on 0

from [Adventure Works]

>>

|||

thanks for the feedback - however, I am relatively new to Analysis Services (and 2005) - and cannot see where this would be created. Are you saying that this is a calculated Dimension (or measure?)

Many thanks

|||

The MDX keyword: UserName will return the name of the current user in an MDX expression, which could be used in many different contexts:

http://msdn2.microsoft.com/en-us/library/ms144884.aspx#expressions_statements_scripts

>>

SQL Server 2005 Books Online

Key Concepts in MDX (MDX)

In MDX, an expression is a combination of identifiers, values, functions, and operators that Analysis Services can evaluate to retrieve an object, such as a set or a member, or a scalar value like a string or a number.

>>

http://msdn2.microsoft.com/en-us/library/ms146016.aspx

>>

SQL Server 2005 Books Online

UserName (MDX)

Returns the domain name and user name of the current connection.

>>

|||Thanks for the feedback.

Dynamic Search SP

Hi,

I'm new to SQL 2005.

I need to create sp that perform search on Users table.

It gets few Parameters.

@.UserName

@.UserStatus

@.UserRole

@.OrderByColumn

All Parameters are optional, and i need to build sql statement that include only the parameters that the sp got on the specific.

I cand do that by concatanating a string and execute it using the sp_executesql().

Is it the best way in sql 2005 ?

Can you please show me an example using Case When or what ever ?

Thanks A lot.

Tok

A very good article on dynamic search that contains more than examples at:

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

Please check it out.

dynamic reporting

Hi Experts...
I want to create report on the fly, for given mdx query , I mean without
having a pre build report format, and I am using FoodMart 2000 sample
database.
pls give me some ideas.....
Thanks in Advance...If I understand what you mean correctly (and using RS) . . . . . I guess
you'd need to create the RDL file dynamically and have it executed
(I think) 8^)
- peteZ
"Sumudu Prasad" <sumudu@.logicalasia.com> wrote in message
news:uo%23XGEhmEHA.512@.TK2MSFTNGP10.phx.gbl...
> Hi Experts...
> I want to create report on the fly, for given mdx query , I mean without
> having a pre build report format, and I am using FoodMart 2000 sample
> database.
> pls give me some ideas.....
> Thanks in Advance...
>
>

Tuesday, March 27, 2012

Dynamic report

Hi all,
I want to create a dynamic report by using code, for ex a report with dynamic column , but dont know where to start and which method is best.
Could you show me some examples about this ?
ThanksThere's a dll that I use called p2smon.dll. This dll has 2 functions:

From scr8_ttxado.pdf which can be found by searching http://support.businessobjects.com/search/advsearch.asp

Using Active Data driver functions

The Active Data driver P2smon.dll (Pdsmon.dll for 16-bit) has two functions that create a TTX file based on a recordset that exists in the VB project. This is the preferred method to create a Data Definition file, as the TTX file will always match the recordset (or vice versa). The two functions available in the DLL are:

CreateFieldDefFile() - Creates a TTX file at runtime based on a recordset.

CreateReportOnRuntimeDS() - Creates a TTX file at runtime based on a recordset. A report (RPT) file is also created off the new TTX file, and there is an option to open the RPT file in the Crystal Reports designer.

These functions are purely for development purposes (they are not required at runtime).

NOTE CreateReportOnRuntimeDS( ) does not place any fields on the report. A blank report is created instead.

The function declarations for CreateFieldDefFile() and CreateReportOnRuntimeDS() are as follows:

CreateFieldDefFile()

Declare Function CreateFieldDefFile Lib "p2smon.dll"(lpUnk As Object, ByVal fileName As String, ByVal bOverWriteExistingFile As Long) As Long

Parameter Description

- LpUnk The active data source used to create the field definition file. In C or C++, this is a pointer to an IUnknown derived COM interface relating to a DAO or ADO Recordset. In Visual Basic, this is a Recordset or Rowset object.

- Filename The path and file name of the field definition file to be created.

- bOverWriteExistingFile If a field definition file already exists with the specified path and file name, this flag indicates whether or not to overwrite that file.

CreateReportOnRuntimeDS()

Declare Function CreateReportOnRuntimeDS Lib "p2smon.dll" ( lpUnk As Object, ByVal reportFile As String, ByVal fieldDefFile As String, ByVal bOverWriteFile As Long, ByVal bLaunchDesigner As Long) As Long

Parameter Description

- LpUnk The active data source used to create the field definition file. In C or C++, this is a pointer to an Iunknown derived COM interface relating to a DAO or ADO Recordset. In Visual Basic, this is a Recordset or Rowset object.

- ReportFile The path and file name of the report file to be created.

- FieldDefFile The path and file name of the field definition file to be created.

- BoverWriteFile If a field definition file already exists with the specified path and file name, this flag indicates whether or not to overwrite that file.

- BlaunchDesigner If True (1), Crystal Reports is launched with the newly created report file opened. Crystal Reports must be installed on the system.

NOTE Since a TTX file is a tab-separated text file, it can be manually created or edited using Microsoft Notepad or any other text editor. This method is not recommended for creating TTX files due to possible typing errors.sql

Dynamic report

Dear all,
I want to create a dynamic report so that I can change some field quickly.
For example: in future, if Field {Report ID} on report header is replaced by {Running User ID}. How can I do once for all reports.
Many thanksWill this work? The idea is to only maintain data in the table.

1. setup a database table that contains user-id and names etc.
2. create a string variable in the report for display.
3. write a routine to detect for the requires condition and pull data off the table.
4. for each report, plug in the same codes created in step-2.

Hope it works for you.

Dynamic Query!

I am trying to create a stored procedure containing a dynamic query.
I am still new to using conditionals in sql, so any help to
get this query running would be appreciated!!!
CREATE PROCEDURE [dbo].[get_emp_list]
@.name VARCHAR(60) = NULL,
@.from_dt SMALLDATETIME = NULL,
@.to_dt SMALLDATETIME = NULL
AS
BEGIN
SELECT
employee_id, first_name, last_name,
company_rep, user_nme, user_pass
FROM
employee
WHERE
IF @.name IS NOT NULL
first_name + ' ' + last_name LIKE @.name
IF @.name IS NOT NULL AND @.from_dt IS NOT NULL
AND start_dt >= from_dt AND <= to_dt
ELSE
start_dt >= from_dt AND <= to_dt
ENDHi
Just check if this solves the purpose
CREATE PROCEDURE [dbo].[get_emp_list]
@.name VARCHAR(60) = NULL,
@.from_dt SMALLDATETIME = NULL,
@.to_dt SMALLDATETIME = NULL
AS
BEGIN
SELECT
employee_id, first_name, last_name,
company_rep, user_nme, user_pass
FROM
employee
WHERE
CASE WHEN @.name IS NOT NULL
first_name + ' ' + last_name LIKE @.name
CASE WHEN @.name IS NOT NULL AND @.from_dt IS NOT NULL
start_dt >= from_dt AND <= to_dt
ELSE
start_dt >= from_dt AND <= to_dt
END
END
best Regards,
Chandra
http://chanduas.blogspot.com/
http://groups.msn.com/SQLResource/
---
"AJ" wrote:

> I am trying to create a stored procedure containing a dynamic query.
> I am still new to using conditionals in sql, so any help to
> get this query running would be appreciated!!!
> CREATE PROCEDURE [dbo].[get_emp_list]
> @.name VARCHAR(60) = NULL,
> @.from_dt SMALLDATETIME = NULL,
> @.to_dt SMALLDATETIME = NULL
> AS
> BEGIN
> SELECT
> employee_id, first_name, last_name,
> company_rep, user_nme, user_pass
> FROM
> employee
> WHERE
> IF @.name IS NOT NULL
> first_name + ' ' + last_name LIKE @.name
> IF @.name IS NOT NULL AND @.from_dt IS NOT NULL
> AND start_dt >= from_dt AND <= to_dt
> ELSE
> start_dt >= from_dt AND <= to_dt
> END|||Well you could approach it very simplistically and just replace all your
different IF cases with OR operations (because that's what they really
are) like this:
SELECT
employee_id, first_name, last_name,
company_rep, user_nme, user_pass
FROM
employee
WHERE (@.name IS NOT NULL and first_name + ' ' + last_name LIKE @.name)
OR (@.name IS NOT NULL AND @.from_dt IS NOT NULL AND start_dt BETWEEN
@.from_dt AND @.to_dt)
OR (start_dt BETWEEN @.from_dt AND @.to_dt)
You could shuffle the WHERE clause around a bit but chances are the
query optimiser will come up with the same plan for the majority of the
variations so you may as well stick to something that you understand and
that's readable (so those who maintain the system after you aren't
bamboozled by your code).
I changed your "<= AND >=" bits to "BETWEEN" because it's a little more
readable IMHO. Also I noticed you left off the '@.' symbol on a couple
references to your proc parameters in the WHERE clause (to_dt & from_dt).
*mike hodgson* |/ database administrator/ | mallesons stephen jaques
*T* +61 (2) 9296 3668 |* F* +61 (2) 9296 3885 |* M* +61 (408) 675 907
*E* mailto:mike.hodgson@.mallesons.nospam.com |* W* http://www.mallesons.com
AJ wrote:

>I am trying to create a stored procedure containing a dynamic query.
>I am still new to using conditionals in sql, so any help to
>get this query running would be appreciated!!!
>CREATE PROCEDURE [dbo].[get_emp_list]
> @.name VARCHAR(60) = NULL,
> @.from_dt SMALLDATETIME = NULL,
> @.to_dt SMALLDATETIME = NULL
>AS
>BEGIN
> SELECT
> employee_id, first_name, last_name,
> company_rep, user_nme, user_pass
> FROM
> employee
> WHERE
> IF @.name IS NOT NULL
> first_name + ' ' + last_name LIKE @.name
> IF @.name IS NOT NULL AND @.from_dt IS NOT NULL
> AND start_dt >= from_dt AND <= to_dt
> ELSE
> start_dt >= from_dt AND <= to_dt
>END
>|||Hmmm... The CASE statement is wrong. I think you mean
WHERE
CASE
WHEN @.name IS NOT NULL
THEN first_name + ' ' + last_name LIKE @.name
WHEN @.name IS NOT NULL AND @.from_dt IS NOT NULL
THEN start_dt >= @.from_dt AND start_dt <= @.to_dt
ELSE
start_dt >= @.from_dt AND start_dt <= @.to_dt
END
But I'm not sure that would work even. BOL says the bit after THEN can be a
ny valid SQL expression but I don't know if "x LIKE y" or "a >= x and a <= b
" are valid in this context (even though they just resolve to a boolean, whi
ch I guess is a valid SQL e
xpression) - never tried that before. At the very least it's a little unort
hodox. Typically a CASE is used to return a specific value to compare somet
hing to like this
WHERE MyCol = (CASE
WHEN a THEN SomeVal
WHEN b THEN SomeOtherVal
ELSE SomeCatchAllVal
END)
Also, the middle case is redundant because it's the same result as the ELSE
case. You could simply write it as
WHERE
CASE
WHEN @.name IS NOT NULL
THEN first_name + ' ' + last_name LIKE @.name
ELSE
start_dt >= @.from_dt AND start_dt <= @.to_dt
END
However, you could get rid of the CASE statement entirely by saying
WHERE first_name + ' ' + last_name LIKE @.name
OR start_dt BETWEEN @.from_dt AND @.to_dt
*mike hodgson* |/ database administrator/ | mallesons stephen jaques
*T* +61 (2) 9296 3668 |* F* +61 (2) 9296 3885 |* M* +61 (408) 675 907
*E* mailto:mike.hodgson@.mallesons.nospam.com |* W* http://www.mallesons.com
Chandra wrote:

>Hi
>Just check if this solves the purpose
>CREATE PROCEDURE [dbo].[get_emp_list]
> @.name VARCHAR(60) = NULL,
> @.from_dt SMALLDATETIME = NULL,
> @.to_dt SMALLDATETIME = NULL
>AS
>BEGIN
> SELECT
> employee_id, first_name, last_name,
> company_rep, user_nme, user_pass
> FROM
> employee
> WHERE
> CASE WHEN @.name IS NOT NULL
> first_name + ' ' + last_name LIKE @.name
> CASE WHEN @.name IS NOT NULL AND @.from_dt IS NOT NULL
> start_dt >= from_dt AND <= to_dt
> ELSE
> start_dt >= from_dt AND <= to_dt
> END
>END
>
>|||Hi all, so far i have adopted the following approach.
If no parameters are supplied i want all records to be selected.
At the moment this isn't catered for in the query below.
My overall logic is:
If @.name is provided filter results with @.name
If @.from_dt is provided filter results with @.from_dt
If @.name and @.from_dt are provided filter with both.
@.if no parameters are provided just select all records.
Can anyone give some modifications to this query to achieve this?
Thanx...
SELECT
employee_id, first_name, last_name,
company_rep, user_nme, user_pass
FROM
employee
WHERE
(@.name IS NOT NULL AND first_name + ' ' + last_name LIKE @.name)
OR
(@.name IS NOT NULL AND @.from_dt IS NOT NULL AND start_dt BETWEEN
@.from_dt AND @.to_dt)
OR
(@.name IS NULL AND start_dt BETWEEN @.from_dt AND @.to_dt)
ORDER BY
last_name|||Sounds like you're trying to do this:
CREATE PROCEDURE [dbo].[get_emp_list]
@.name VARCHAR(60) = '%',
@.from_dt SMALLDATETIME = '19000101',
@.to_dt SMALLDATETIME = '20790606'
AS
BEGIN
SELECT
employee_id, first_name, last_name,
company_rep, user_nme, user_pass
FROM
employee
WHERE first_name + ' ' + last_name LIKE @.name
AND start_dt >= @.from_dt
AND start_dt <= @.to_dt
END
This goes along the lines of factor in each parameter in the where
clause but if no value is passed into the proc for each specific
parameter then a default value will be used, for each parameter, such
that it won't limit the resultset at all (ie. any @.name string, the min
@.from_dt value and the max @.to_dt value for the datatypes you chose).
*mike hodgson* |/ database administrator/ | mallesons stephen jaques
*T* +61 (2) 9296 3668 |* F* +61 (2) 9296 3885 |* M* +61 (408) 675 907
*E* mailto:mike.hodgson@.mallesons.nospam.com |* W* http://www.mallesons.com
AJ wrote:

>Hi all, so far i have adopted the following approach.
>If no parameters are supplied i want all records to be selected.
>At the moment this isn't catered for in the query below.
>My overall logic is:
>If @.name is provided filter results with @.name
>If @.from_dt is provided filter results with @.from_dt
>If @.name and @.from_dt are provided filter with both.
>@.if no parameters are provided just select all records.
>Can anyone give some modifications to this query to achieve this?
>Thanx...
> SELECT
> employee_id, first_name, last_name,
> company_rep, user_nme, user_pass
> FROM
> employee
> WHERE
> (@.name IS NOT NULL AND first_name + ' ' + last_name LIKE @.name)
> OR
> (@.name IS NOT NULL AND @.from_dt IS NOT NULL AND start_dt BETWEEN
>@.from_dt AND @.to_dt)
> OR
> (@.name IS NULL AND start_dt BETWEEN @.from_dt AND @.to_dt)
> ORDER BY
> last_name
>|||One small caveat to Mike's excellent suggestion - the technique he proposes
requires that none of the columns (first_name, last_name, start_dt, and
end_dt columns) be nullable. If any of the rows contains nulls in one or
more of those columns, then you will not match that row. Since you did not
post any DDL, we do not know the details of the table being searched, so
this may or may not apply in your case. In the future, please post DDL and
sample data so you have the best chance of receiving the most complete
answer possible.
Erland Sommarskog has a great article about dynamic search criteria at:
http://www.sommarskog.se/dyn-search.html
ITHT
Jeremy Williams
"Mike Hodgson" <mike.hodgson@.mallesons.nospam.com> wrote in message
news:%23xxsVZmaFHA.3400@.tk2msftngp13.phx.gbl...
Sounds like you're trying to do this:
CREATE PROCEDURE [dbo].[get_emp_list]
@.name VARCHAR(60) = '%',
@.from_dt SMALLDATETIME = '19000101',
@.to_dt SMALLDATETIME = '20790606'
AS
BEGIN
SELECT
employee_id, first_name, last_name,
company_rep, user_nme, user_pass
FROM
employee
WHERE first_name + ' ' + last_name LIKE @.name
AND start_dt >= @.from_dt
AND start_dt <= @.to_dt
END
This goes along the lines of factor in each parameter in the where clause
but if no value is passed into the proc for each specific parameter then a
default value will be used, for each parameter, such that it won't limit the
resultset at all (ie. any @.name string, the min @.from_dt value and the max
@.to_dt value for the datatypes you chose).
mike hodgson | database administrator | mallesons stephen jaques
T +61 (2) 9296 3668 | F +61 (2) 9296 3885 | M +61 (408) 675 907
E mailto:mike.hodgson@.mallesons.nospam.com | W http://www.mallesons.com
AJ wrote:
Hi all, so far i have adopted the following approach.
If no parameters are supplied i want all records to be selected.
At the moment this isn't catered for in the query below.
My overall logic is:
If @.name is provided filter results with @.name
If @.from_dt is provided filter results with @.from_dt
If @.name and @.from_dt are provided filter with both.
@.if no parameters are provided just select all records.
Can anyone give some modifications to this query to achieve this?
Thanx...
SELECT
employee_id, first_name, last_name,
company_rep, user_nme, user_pass
FROM
employee
WHERE
(@.name IS NOT NULL AND first_name + ' ' + last_name LIKE @.name)
OR
(@.name IS NOT NULL AND @.from_dt IS NOT NULL AND start_dt BETWEEN
@.from_dt AND @.to_dt)
OR
(@.name IS NULL AND start_dt BETWEEN @.from_dt AND @.to_dt)
ORDER BY
last_name|||No, SQL has a CASE expression **not** a CASE statement. Big
difference! Expressionds return a value: they do not control flow of
control.|||Exactly what I was getting at (did you read my whole post?).
*mike hodgson* |/ database administrator/ | mallesons stephen jaques
*T* +61 (2) 9296 3668 |* F* +61 (2) 9296 3885 |* M* +61 (408) 675 907
*E* mailto:mike.hodgson@.mallesons.nospam.com |* W* http://www.mallesons.com
--CELKO-- wrote:

>No, SQL has a CASE expression **not** a CASE statement. Big
>difference! Expressionds return a value: they do not control flow of
>control.
>
>

dynamic Query - ODBC connectivity

I am trying to create Dynamic Query.Connecting to Sybase database source through ODBC, but I try to pass Paremeter by using @.. It says error. Also If i pass &Parameters!Parametername.Value is also not working.Its not saying error for string values but for numeric it says reror. Also in the Query builder i am not able to give expression by giving = "select some Query".

I fgiven an solution or example would be great. Thanks in advance.

I'm not sure but ... does ODBC support named parameters?
Try using ? as parameter, not a questionmark as prefix but like this:

select *
from bla
where something = ?

|||

ODBC is not supporting naming parameter.

I tried with ? working to pass parameter to my query

It was named as Paramater1 when i preview the report and automatically taking the value as string format.Can we change the description and data type?

But I am trying to use Report parameter. i.e. I am getting the values in combo box if in preview the values i select in the query.

But i am unable to use the Report parametr in the query. could anyone help out passing report parameter to sysbase ODBC query

Thanks Hypo for you valuable respons.

Dynamic Query :: HELP!

I'm the new guy and I could use a hand. Any insight would be appreciated.

Basically my task is to create a dynamic way to merge columns from multiple rows. Way the table is set up data is imported and one entry may be up to 3 rows one column from each row can be merged to form a long description, I would like to create a view that would allow you to dynamically query this data and have the description be merged in the result set.

row1 x y z
row2 x b z
row3 x m z

results should look like :: x, (y + b + m) , z

Thank you in advance for any help you can provide!numbers? you can SUM() them, but description? can't be done

you'll need to write some sort of script, either in the application that calls the database, or mayhaps in a stored proc that can cursor through the rows|||numbers? you can SUM() them, but description? can't be done

you'll need to write some sort of script, either in the application that calls the database, or mayhaps in a stored proc that can cursor through the rows

Unfortunately the data is all of char type. :confused:|||Any suggestions of how to go about doing this using a procedure?|||http://www.dbforums.com/t1038027.html|||Thanks for the link...I can't say I totally understand the function though.

I hate to ask this, and sound like an idiot, but can anyone give me the english break down?|||Cut and paste this code in to Query Analyzer...

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=40520

Monday, March 26, 2012

dynamic query

Hello friends,

I want to create a dynamic query based on input of the parameter.

If the user passes nothing then all fields should be displayed else use query based on parameter.

I had view sample of MSDN ,but I got error [BC30203].

Is there another way to it ?Please help.

I use:

= iif(Parameters!SQLQuery.Value<>"",Parameters!SQLQuery.Value,"SELECT somecolumn from sometable") as "select statement"

and provide a query in the SQLQuery-Parameter..

You could also use:

= iif(Parameters!SomeID.Value<>"","SELECT somecolumn from sometable where id=" & Parameters!SQLQuery.Value,"SELECT somecolumn from sometable where id=123")

|||

Thanks For Your Reply

But I m still confusing.

I had used the iif (condition) in the generic query designer but i cannot retrive the fields which I want from the query.

The Query is executing but the data set does not contain any fields.

for eg:

="Select Idnummer,.....

iif(parameter is null,nothing,"AND ART IN ( " & parameter.value & ")")

Please reply sooner.

|||

You can't check your query anymore, thats right. When writing the query as ="select .. " & some_condition .. Hitting the "!"-Button has no effect.. This statement is evaluated at runtime.. So, you have to go to Preview-Mode and check if the result looks right..

If you are missing the Fields!.. for report design, the easiest way is to execute a "normal" sql-statement once (this will add the fields) and then transform your sql-string..

|||

Dynamic query should be avoided wherever possible. It is much harder to do (as you have seen).

I do this, I have a parameter that says All and returns a value of All (it could also return a number if a number field, just make it a value that does not exist in the database.

Do this:

selct * from sometable where (somefield = @.MyParam or @.MyParam = 'All') and ...

|||

I dunno if this is better, but should do the same thing:

The query will be:

select * from TableName
where FieldName LIKE (CASE WHEN @.param IS NULL THEN '%' ELSE @.param END)

|||

Hello Sir,

How can I implement "ALL" in my parameter

The table field does not contain 'ALL" .

If the parameter selected is 'ALL',then query should execute with the parameter contaning 'ALL' the values.Then my problem could be solve if the parameter contains 'ALL'.

please give a sample to implement 'ALL' in my parameter and in query.

Please reply soon.

Thanks

|||

u can use the query in this way,


SELECT AreaName, AreaCode
FROM Area
UNION
SELECT ' All' AS Areaname, '' AS AreaCode
ORDER BY AreaName

This will add 'All' n ur drop down box n using case statement in query u can get the desired results.

regards

Satyendra

Dynamic Query

Hi there
I am trying to create a report with a proc that has dynamic column headers.
eg TonsHarvested1998, TonsHarvested2000, etc.
The problem I am experiencing is that these columns are not displayed in the
fields editor box and I have no idea as to how I can get them displayed in
my textboxes.
Can anyone give me any ideas as to how I can sort this out.
Thanks
KershniFirst run the static version of the query which will populate the fields
list and then replace the query with the dynamic version. You can also
populate the fields list manually (Dataset dialog box -> Fields tab.)
--
Ravi Mumulla (Microsoft)
SQL Server Reporting Services
This posting is provided "AS IS" with no warranties, and confers no rights.
"Kershni Chetty" <support@.sqrsoftware.com> wrote in message
news:%23xwvy6GeEHA.2848@.TK2MSFTNGP10.phx.gbl...
> Hi there
> I am trying to create a report with a proc that has dynamic column
headers.
> eg TonsHarvested1998, TonsHarvested2000, etc.
> The problem I am experiencing is that these columns are not displayed in
the
> fields editor box and I have no idea as to how I can get them displayed in
> my textboxes.
> Can anyone give me any ideas as to how I can sort this out.
> Thanks
> Kershni
>sql

dynamic pivot table

hi

i am trying to create a dynamic sql statement so i can pivot information...

my problem is that when i run this query i get the error information below. i am running sql server 2000... can this run in 2005?

this runs perfectly when only one record is returned in the sub query...

declare @.query varchar(300)
select @.query = 'Select '+ char(10) + (
select Code
+'case when Code = '''+ Code +''' then count(Code) else 0 end as '+Code+''+char(10)
as [text()]

from WipAvailable WA
)+ char(10) +
' from WipMaster group by Code'

select @.query
exec (@.query)

Server: Msg 512, Level 16, State 1, Line 3
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.

(1 row(s) affected)

u have given the answer..."this runs perfectly when only one record is returned in the sub query...", in this case the outer query just expects one result to be returned by the subquery... and it'll give the same error in 2005 as well... u need to look at the logic...

i dont know ur exact aim..if pivot is the aim , there is a pivot operator u can use in sql server 2005, to make row data into columns...

|||

if you are using the sql server 2005 then use Pivot operator,

example,

SELECT
[1] as [Code-1],
[2] as [Code-2],
[3] as [Code-3]
FROM
(SELECT Code from WipAvailable) Master
PIVOT
(Count(Code) for Code in ([1],[2],[3]))
AS pvt

to achive the above query dynamically use the following statement,

Declare @.Columns as varchar(1000);
Declare @.Values as varchar(1000);
Declare @.Query as varchar(3000);
select
@.Columns = Isnull(@.Columns,'') + '[' + Code + '] as [Code-' + Code + '],' ,
@.Values = Isnull(@.Values,'') + '[' + Code + '],'
From WipMaster

select @.Columns = Substring(@.Columns,1,Len(@.Columns)-1),
@.Values = Substring(@.Values,1,Len(@.Values)-1)

select @.Query = 'Select ' + @.Columns + ' From (Select Code From WipAvailable) Master'
+ ' Pivot (Count(Code) for Code in (' + @.values + ')) as Pvt'

Exec (@.Query)

|||

To work on SQL Server 2000,

Use the following query

Select
(Select count(Code) from WipAvailable where Code=1) as [1]
,(Select count(Code) from WipAvailable where Code=2) as [2]
,(Select count(Code) from WipAvailable where Code=3) as [3]

To achive the above query dynamically use the following statement


Declare @.query varchar(8000)
select @.query = Isnull(@.query,'') + '(Select count(Code) '
+ char(10) +
' from WipAvailable where Code=' + Code + ') as [' + Code + '],'
from Wipmaster Master
Order By Code
select @.query = 'Select ' + Substring(@.query,1,Len(@.query)-1)
Exec (@.query)

Thursday, March 22, 2012

Dynamic Parameters in 8.5

Will 8.5 allow you to make parameters dynamic.
Specifically is it possible to create a parameter that when that table and or field in SQL is changed, it will update my crystal report with those changes? If not in a parameter is there anyway to do this?If you're going to use Crystal Reports alone that will not be possible since parameters are static.

I don't know how to do it but if you use stored procedures maybe you can make it dynamic.

Dynamic Parameters and using an "All" Value

I have a report that I need to create a parameter of Territories which I can
do with the following Data set...
Territories>>
Select Name
From dbo.territory
and
Contacts>>
SELECT TER.Name AS Territory, CAST(CON.ContactId AS varchar(36)) AS
ContactID, CON.FirstName, CON.LastName, CON.JobTitle, CAD.Line1, CAD.City,
CAD.StateOrProvince, CAD.PostalCode, CON.Telephone1 AS
businessphone, CON.MobilePhone, CON.Telephone3 AS rangephone,
CAST(ACT.AccountId AS varchar(36)) AS AccountID,
ACT.Name AS companyname, CAD.StateOrProvince AS company_stateorprovince
FROM ContactBase CON LEFT OUTER JOIN
CustomerAddressBase CAD ON CON.ContactId = CAD.ParentId AND CAD.AddressNumber = 1 LEFT OUTER JOIN
Account ACT ON CON.AccountId = ACT.AccountId LEFT
OUTER JOIN
CustomerAddressBase CAA ON ACT.AccountId = CAD.ParentId AND CAD.AddressNumber = 2 LEFT OUTER JOIN
TerritoryBase TER ON ACT.TerritoryId = TER.TerritoryId
WHERE (TER.Name IN (@.Territories))
ORDER BY TER.Name, CAD.StateOrProvince, ACT.Name, CON.LastName
I cannot create an All value and use it in the Parameters, for my parameters
values I was doing non Query and setting them to the name, but for All I
tried Northeast,Southest,West. That does not error out, it just doesn't
return any data. The other values work. Very Bizarre.
Any ideas of what I can do? The territory table uses GUIDs as IDs, So I
cannot easily create an integer which could solve the issue.Hi!
We had the same problem but did this.
In your territories select case do the following:
Select '%' as 'Name', 'All' as 'Label'
UNION
Select Name, Name as 'Label'
From dbo.territory and Contacts
This would give you a table looking like
Name Label
% All
Ottawa Ottawa
etc etc
The you would change the dataset statement to :
WHERE (TER.Name LIKE (@.Territories))
Hope this helps,
Erik
"Jack Bender" wrote:
> I have a report that I need to create a parameter of Territories which I can
> do with the following Data set...
> Territories>>
> Select Name
> From dbo.territory
> and
> Contacts>>
> SELECT TER.Name AS Territory, CAST(CON.ContactId AS varchar(36)) AS
> ContactID, CON.FirstName, CON.LastName, CON.JobTitle, CAD.Line1, CAD.City,
> CAD.StateOrProvince, CAD.PostalCode, CON.Telephone1 AS
> businessphone, CON.MobilePhone, CON.Telephone3 AS rangephone,
> CAST(ACT.AccountId AS varchar(36)) AS AccountID,
> ACT.Name AS companyname, CAD.StateOrProvince AS company_stateorprovince
> FROM ContactBase CON LEFT OUTER JOIN
> CustomerAddressBase CAD ON CON.ContactId => CAD.ParentId AND CAD.AddressNumber = 1 LEFT OUTER JOIN
> Account ACT ON CON.AccountId = ACT.AccountId LEFT
> OUTER JOIN
> CustomerAddressBase CAA ON ACT.AccountId => CAD.ParentId AND CAD.AddressNumber = 2 LEFT OUTER JOIN
> TerritoryBase TER ON ACT.TerritoryId = TER.TerritoryId
> WHERE (TER.Name IN (@.Territories))
> ORDER BY TER.Name, CAD.StateOrProvince, ACT.Name, CON.LastName
> I cannot create an All value and use it in the Parameters, for my parameters
> values I was doing non Query and setting them to the name, but for All I
> tried Northeast,Southest,West. That does not error out, it just doesn't
> return any data. The other values work. Very Bizarre.
> Any ideas of what I can do? The territory table uses GUIDs as IDs, So I
> cannot easily create an integer which could solve the issue.
>sql

Dynamic Parameter

My DB has 3 tables Employee, Department, Job
I want to create a report with two parameters.
Parameter 1 Options: Employee, Department or Job
Parameter 2 Options: When user selects Employee from parameter 1, all
employee names will be made available to select in parameter 2, When user
selects department from parameter 1, all department names will be made
available to select in parameter 2.
How would one doe this? Any help is appreciated.I did this for a Northwind DB. Here is how my RDL looked. Multiple queries
and data sets returned.
I changed the names of my data source and data sets. It should still work
against a Northwind DB.
<?xml version="1.0" encoding="utf-8"?>
<Report
xmlns="http://schemas.microsoft.com/sqlserver/reporting/2003/10/reportdefini
tion"
xmlns:rd="">http://schemas.microsoft.com/SQLServer/reporting/reportdesigner">
<DataSources>
<DataSource Name="ds1">
<rd:DataSourceID>2122d420-3823-467b-8d49-89744c792684</rd:DataSourceID>
<ConnectionProperties>
<DataProvider>SQL</DataProvider>
<ConnectString>data source=servername;initial
catalog=Northwind</ConnectString>
</ConnectionProperties>
</DataSource>
</DataSources>
<rd:ReportID>48c77212-85fb-46c9-9347-e0ecf74aa394</rd:ReportID>
<Body>
<ReportItems>
<Textbox Name="textbox_2">
<Style>
<BackgroundColor>Yellow</BackgroundColor>
<TextAlign>Left</TextAlign>
<FontSize>9pt</FontSize>
</Style>
<Height>.5 in</Height>
<Width>3 in</Width>
<CanGrow>true</CanGrow>
<Value>=Fields!TestResult.Value
+ "********Parameters CustomerIDParam Value: " +
Parameters!CustomerIDParam.Value
+ "********Parameters EmployeeIDParam Value: " +
Str(Parameters!EmployeeIDParam.Value)
</Value>
<Top>.5 in</Top>
<Left>0 in</Left>
</Textbox>
<Textbox Name="textbox_1">
<Style>
<BackgroundColor>Red</BackgroundColor>
<FontSize>14pt</FontSize>
</Style>
<Height>.5 in</Height>
<Width>3 in</Width>
<CanGrow>true</CanGrow>
<Value>Test Result Below:</Value>
<Top>0 in</Top>
<Left>0 in</Left>
</Textbox>
</ReportItems>
<Height>1.705in</Height>
</Body>
<rd:DrawGrid>true</rd:DrawGrid>
<DataSets>
<DataSet Name="mydataset">
<Fields>
<Field Name="TestResult">
<DataField>TestResult</DataField>
<rd:TypeName>System.String</rd:TypeName>
</Field>
<Field Name="CustomerID">
<DataField>CustomerID</DataField>
<rd:TypeName>System.String</rd:TypeName>
</Field>
<Field Name="EmployeeID">
<DataField>EmployeeID</DataField>
<rd:TypeName>System.Int32</rd:TypeName>
</Field>
</Fields>
<Query>
<DataSourceName>ds1</DataSourceName>
<CommandType>Text</CommandType>
<CommandText>SELECT * , 'Test Passed' as "TestResult" FROM Orders
WHERE EmployeeID = @.EmployeeIDParam AND CustomerID =@.CustomerIDParam</CommandText>
<rd:UseGenericDesigner>true</rd:UseGenericDesigner>
<QueryParameters>
<QueryParameter Name="@.EmployeeIDParam">
<Value>=Parameters!EmployeeIDParam.Value</Value>
</QueryParameter>
<QueryParameter Name="@.CustomerIDParam">
<Value>=Parameters!CustomerIDParam.Value</Value>
</QueryParameter>
</QueryParameters>
</Query>
</DataSet>
<DataSet Name="mydataset2">
<Fields>
<Field Name="EmployeeID">
<DataField>EmployeeID</DataField>
<rd:TypeName>System.Int32</rd:TypeName>
</Field>
</Fields>
<Query>
<DataSourceName>ds1</DataSourceName>
<CommandType>Text</CommandType>
<CommandText>SELECT DISTINCT EmployeeID FROM Employees
ORDER BY EmployeeID ASC</CommandText>
<rd:UseGenericDesigner>true</rd:UseGenericDesigner>
</Query>
</DataSet>
<DataSet Name="mydataset3">
<Fields>
<Field Name="CustomerID">
<DataField>CustomerID</DataField>
<rd:TypeName>System.String</rd:TypeName>
</Field>
</Fields>
<Query>
<DataSourceName>ds1</DataSourceName>
<CommandType>Text</CommandType>
<CommandText>SELECT DISTINCT CustomerID FROM Orders
WHERE EmployeeID = @.EmployeeIDParam ORDER BY CustomerID ASC</CommandText>
<rd:UseGenericDesigner>true</rd:UseGenericDesigner>
<QueryParameters>
<QueryParameter Name="@.EmployeeIDParam">
<Value>=Parameters!EmployeeIDParam.Value</Value>
</QueryParameter>
</QueryParameters>
</Query>
</DataSet>
</DataSets>
<Language>en-US</Language>
<RightMargin>1in</RightMargin>
<BottomMargin>1in</BottomMargin>
<TopMargin>1in</TopMargin>
<rd:SnapToGrid>true</rd:SnapToGrid>
<Width>5in</Width>
<LeftMargin>1in</LeftMargin>
<ReportParameters>
<ReportParameter Name="EmployeeID">
<DataType>Integer</DataType>
<DefaultValue>
<Values>
<Value>1</Value>
</Values>
</DefaultValue>
<ValidValues>
<DataSetReference>
<DataSetName>mydataset2</DataSetName>
<ValueField>EmployeeID</ValueField>
<LabelField>EmployeeID</LabelField>
</DataSetReference>
</ValidValues>
<Prompt>Employee ID :</Prompt>
</ReportParameter>
<ReportParameter Name="EmployeeIDParam">
<DataType>Integer</DataType>
<DefaultValue>
<Values>
<Value>=Parameters!EmployeeID.Value</Value>
</Values>
</DefaultValue>
<Prompt> </Prompt>
</ReportParameter>
<ReportParameter Name="CustomerIDParam">
<DataType>String</DataType>
<DefaultValue>
<Values>
<Value>VINET</Value>
</Values>
</DefaultValue>
<ValidValues>
<DataSetReference>
<DataSetName>mydataset3</DataSetName>
<ValueField>CustomerID</ValueField>
<LabelField>CustomerID</LabelField>
</DataSetReference>
</ValidValues>
<Prompt>Customer ID :</Prompt>
</ReportParameter>
</ReportParameters>
</Report>
--
| Thread-Topic: Dynamic Parameter
| thread-index: AcUFhs+wyP3Cs1ONTxSLxYdNcM59XQ==| X-WBNR-Posting-Host: 70.66.0.254
| From: "=?Utf-8?B?U0FjYW51Y2s=?=" <SAcanuck@.discussions.microsoft.com>
| Subject: Dynamic Parameter
| Date: Fri, 28 Jan 2005 14:15:01 -0800
| Lines: 12
| Message-ID: <AE5AB9C9-7340-4ED3-9EC6-3F5DB22834AA@.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.reportingsvcs
| NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.1.29
| Path: cpmsftngxa10.phx.gbl!TK2MSFTNGXA03.phx.gbl
| Xref: cpmsftngxa10.phx.gbl microsoft.public.sqlserver.reportingsvcs:41264
| X-Tomcat-NG: microsoft.public.sqlserver.reportingsvcs
|
| My DB has 3 tables Employee, Department, Job
|
| I want to create a report with two parameters.
|
| Parameter 1 Options: Employee, Department or Job
|
| Parameter 2 Options: When user selects Employee from parameter 1, all
| employee names will be made available to select in parameter 2, When
user
| selects department from parameter 1, all department names will be made
| available to select in parameter 2.
|
| How would one doe this? Any help is appreciated.
||||It is not necessary to dive into this RDL code.
Go to the online help from Reporting Services. There is a chapter Create
Report (or similare) and there is a description of using Parameters. On the
end of this article is your question answered in the best way.
""Brad Syputa - MS"" wrote:
> I did this for a Northwind DB. Here is how my RDL looked. Multiple queries
> and data sets returned.
> I changed the names of my data source and data sets. It should still work
> against a Northwind DB.
> <?xml version="1.0" encoding="utf-8"?>
> <Report
> xmlns="http://schemas.microsoft.com/sqlserver/reporting/2003/10/reportdefini
> tion"
> xmlns:rd="">http://schemas.microsoft.com/SQLServer/reporting/reportdesigner">
> <DataSources>
> <DataSource Name="ds1">
> <rd:DataSourceID>2122d420-3823-467b-8d49-89744c792684</rd:DataSourceID>
> <ConnectionProperties>
> <DataProvider>SQL</DataProvider>
> <ConnectString>data source=servername;initial
> catalog=Northwind</ConnectString>
> </ConnectionProperties>
> </DataSource>
> </DataSources>
> <rd:ReportID>48c77212-85fb-46c9-9347-e0ecf74aa394</rd:ReportID>
> <Body>
> <ReportItems>
> <Textbox Name="textbox_2">
> <Style>
> <BackgroundColor>Yellow</BackgroundColor>
> <TextAlign>Left</TextAlign>
> <FontSize>9pt</FontSize>
> </Style>
> <Height>.5 in</Height>
> <Width>3 in</Width>
> <CanGrow>true</CanGrow>
> <Value>=Fields!TestResult.Value
> + "********Parameters CustomerIDParam Value: " +
> Parameters!CustomerIDParam.Value
> + "********Parameters EmployeeIDParam Value: " +
> Str(Parameters!EmployeeIDParam.Value)
> </Value>
> <Top>.5 in</Top>
> <Left>0 in</Left>
> </Textbox>
> <Textbox Name="textbox_1">
> <Style>
> <BackgroundColor>Red</BackgroundColor>
> <FontSize>14pt</FontSize>
> </Style>
> <Height>.5 in</Height>
> <Width>3 in</Width>
> <CanGrow>true</CanGrow>
> <Value>Test Result Below:</Value>
> <Top>0 in</Top>
> <Left>0 in</Left>
> </Textbox>
> </ReportItems>
> <Height>1.705in</Height>
> </Body>
> <rd:DrawGrid>true</rd:DrawGrid>
> <DataSets>
> <DataSet Name="mydataset">
> <Fields>
> <Field Name="TestResult">
> <DataField>TestResult</DataField>
> <rd:TypeName>System.String</rd:TypeName>
> </Field>
> <Field Name="CustomerID">
> <DataField>CustomerID</DataField>
> <rd:TypeName>System.String</rd:TypeName>
> </Field>
> <Field Name="EmployeeID">
> <DataField>EmployeeID</DataField>
> <rd:TypeName>System.Int32</rd:TypeName>
> </Field>
> </Fields>
> <Query>
> <DataSourceName>ds1</DataSourceName>
> <CommandType>Text</CommandType>
> <CommandText>SELECT * , 'Test Passed' as "TestResult" FROM Orders
> WHERE EmployeeID = @.EmployeeIDParam AND CustomerID => @.CustomerIDParam</CommandText>
> <rd:UseGenericDesigner>true</rd:UseGenericDesigner>
> <QueryParameters>
> <QueryParameter Name="@.EmployeeIDParam">
> <Value>=Parameters!EmployeeIDParam.Value</Value>
> </QueryParameter>
> <QueryParameter Name="@.CustomerIDParam">
> <Value>=Parameters!CustomerIDParam.Value</Value>
> </QueryParameter>
> </QueryParameters>
> </Query>
> </DataSet>
> <DataSet Name="mydataset2">
> <Fields>
> <Field Name="EmployeeID">
> <DataField>EmployeeID</DataField>
> <rd:TypeName>System.Int32</rd:TypeName>
> </Field>
> </Fields>
> <Query>
> <DataSourceName>ds1</DataSourceName>
> <CommandType>Text</CommandType>
> <CommandText>SELECT DISTINCT EmployeeID FROM Employees
> ORDER BY EmployeeID ASC</CommandText>
> <rd:UseGenericDesigner>true</rd:UseGenericDesigner>
> </Query>
> </DataSet>
> <DataSet Name="mydataset3">
> <Fields>
> <Field Name="CustomerID">
> <DataField>CustomerID</DataField>
> <rd:TypeName>System.String</rd:TypeName>
> </Field>
> </Fields>
> <Query>
> <DataSourceName>ds1</DataSourceName>
> <CommandType>Text</CommandType>
> <CommandText>SELECT DISTINCT CustomerID FROM Orders
> WHERE EmployeeID = @.EmployeeIDParam ORDER BY CustomerID ASC</CommandText>
> <rd:UseGenericDesigner>true</rd:UseGenericDesigner>
> <QueryParameters>
> <QueryParameter Name="@.EmployeeIDParam">
> <Value>=Parameters!EmployeeIDParam.Value</Value>
> </QueryParameter>
> </QueryParameters>
> </Query>
> </DataSet>
> </DataSets>
> <Language>en-US</Language>
> <RightMargin>1in</RightMargin>
> <BottomMargin>1in</BottomMargin>
> <TopMargin>1in</TopMargin>
> <rd:SnapToGrid>true</rd:SnapToGrid>
> <Width>5in</Width>
> <LeftMargin>1in</LeftMargin>
> <ReportParameters>
> <ReportParameter Name="EmployeeID">
> <DataType>Integer</DataType>
> <DefaultValue>
> <Values>
> <Value>1</Value>
> </Values>
> </DefaultValue>
> <ValidValues>
> <DataSetReference>
> <DataSetName>mydataset2</DataSetName>
> <ValueField>EmployeeID</ValueField>
> <LabelField>EmployeeID</LabelField>
> </DataSetReference>
> </ValidValues>
> <Prompt>Employee ID :</Prompt>
> </ReportParameter>
> <ReportParameter Name="EmployeeIDParam">
> <DataType>Integer</DataType>
> <DefaultValue>
> <Values>
> <Value>=Parameters!EmployeeID.Value</Value>
> </Values>
> </DefaultValue>
> <Prompt> </Prompt>
> </ReportParameter>
> <ReportParameter Name="CustomerIDParam">
> <DataType>String</DataType>
> <DefaultValue>
> <Values>
> <Value>VINET</Value>
> </Values>
> </DefaultValue>
> <ValidValues>
> <DataSetReference>
> <DataSetName>mydataset3</DataSetName>
> <ValueField>CustomerID</ValueField>
> <LabelField>CustomerID</LabelField>
> </DataSetReference>
> </ValidValues>
> <Prompt>Customer ID :</Prompt>
> </ReportParameter>
> </ReportParameters>
> </Report>
> --
> | Thread-Topic: Dynamic Parameter
> | thread-index: AcUFhs+wyP3Cs1ONTxSLxYdNcM59XQ==> | X-WBNR-Posting-Host: 70.66.0.254
> | From: "=?Utf-8?B?U0FjYW51Y2s=?=" <SAcanuck@.discussions.microsoft.com>
> | Subject: Dynamic Parameter
> | Date: Fri, 28 Jan 2005 14:15:01 -0800
> | Lines: 12
> | Message-ID: <AE5AB9C9-7340-4ED3-9EC6-3F5DB22834AA@.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.reportingsvcs
> | NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.1.29
> | Path: cpmsftngxa10.phx.gbl!TK2MSFTNGXA03.phx.gbl
> | Xref: cpmsftngxa10.phx.gbl microsoft.public.sqlserver.reportingsvcs:41264
> | X-Tomcat-NG: microsoft.public.sqlserver.reportingsvcs
> |
> | My DB has 3 tables Employee, Department, Job
> |
> | I want to create a report with two parameters.
> |
> | Parameter 1 Options: Employee, Department or Job
> |
> | Parameter 2 Options: When user selects Employee from parameter 1, all
> | employee names will be made available to select in parameter 2, When
> user
> | selects department from parameter 1, all department names will be made
> | available to select in parameter 2.
> |
> | How would one doe this? Any help is appreciated.
> |
>|||I had a look at the reporting services books online and it had a description
on how to use a basiv dynamic parameter...my requirement is a bit more
advanced than the given example.
"Dev Main" wrote:
> It is not necessary to dive into this RDL code.
> Go to the online help from Reporting Services. There is a chapter Create
> Report (or similare) and there is a description of using Parameters. On the
> end of this article is your question answered in the best way.
>
> ""Brad Syputa - MS"" wrote:
> > I did this for a Northwind DB. Here is how my RDL looked. Multiple queries
> > and data sets returned.
> >
> > I changed the names of my data source and data sets. It should still work
> > against a Northwind DB.
> >
> > <?xml version="1.0" encoding="utf-8"?>
> > <Report
> > xmlns="http://schemas.microsoft.com/sqlserver/reporting/2003/10/reportdefini
> > tion"
> > xmlns:rd="">http://schemas.microsoft.com/SQLServer/reporting/reportdesigner">
> > <DataSources>
> > <DataSource Name="ds1">
> >
> > <rd:DataSourceID>2122d420-3823-467b-8d49-89744c792684</rd:DataSourceID>
> > <ConnectionProperties>
> > <DataProvider>SQL</DataProvider>
> > <ConnectString>data source=servername;initial
> > catalog=Northwind</ConnectString>
> > </ConnectionProperties>
> > </DataSource>
> > </DataSources>
> > <rd:ReportID>48c77212-85fb-46c9-9347-e0ecf74aa394</rd:ReportID>
> > <Body>
> > <ReportItems>
> > <Textbox Name="textbox_2">
> > <Style>
> > <BackgroundColor>Yellow</BackgroundColor>
> > <TextAlign>Left</TextAlign>
> > <FontSize>9pt</FontSize>
> > </Style>
> > <Height>.5 in</Height>
> > <Width>3 in</Width>
> > <CanGrow>true</CanGrow>
> > <Value>=Fields!TestResult.Value
> > + "********Parameters CustomerIDParam Value: " +
> > Parameters!CustomerIDParam.Value
> > + "********Parameters EmployeeIDParam Value: " +
> > Str(Parameters!EmployeeIDParam.Value)
> > </Value>
> > <Top>.5 in</Top>
> > <Left>0 in</Left>
> > </Textbox>
> > <Textbox Name="textbox_1">
> > <Style>
> > <BackgroundColor>Red</BackgroundColor>
> > <FontSize>14pt</FontSize>
> > </Style>
> > <Height>.5 in</Height>
> > <Width>3 in</Width>
> > <CanGrow>true</CanGrow>
> > <Value>Test Result Below:</Value>
> > <Top>0 in</Top>
> > <Left>0 in</Left>
> > </Textbox>
> > </ReportItems>
> > <Height>1.705in</Height>
> > </Body>
> > <rd:DrawGrid>true</rd:DrawGrid>
> > <DataSets>
> > <DataSet Name="mydataset">
> > <Fields>
> > <Field Name="TestResult">
> > <DataField>TestResult</DataField>
> > <rd:TypeName>System.String</rd:TypeName>
> > </Field>
> > <Field Name="CustomerID">
> > <DataField>CustomerID</DataField>
> > <rd:TypeName>System.String</rd:TypeName>
> > </Field>
> > <Field Name="EmployeeID">
> > <DataField>EmployeeID</DataField>
> > <rd:TypeName>System.Int32</rd:TypeName>
> > </Field>
> > </Fields>
> > <Query>
> > <DataSourceName>ds1</DataSourceName>
> > <CommandType>Text</CommandType>
> > <CommandText>SELECT * , 'Test Passed' as "TestResult" FROM Orders
> > WHERE EmployeeID = @.EmployeeIDParam AND CustomerID => > @.CustomerIDParam</CommandText>
> > <rd:UseGenericDesigner>true</rd:UseGenericDesigner>
> > <QueryParameters>
> > <QueryParameter Name="@.EmployeeIDParam">
> > <Value>=Parameters!EmployeeIDParam.Value</Value>
> > </QueryParameter>
> > <QueryParameter Name="@.CustomerIDParam">
> > <Value>=Parameters!CustomerIDParam.Value</Value>
> > </QueryParameter>
> > </QueryParameters>
> > </Query>
> > </DataSet>
> > <DataSet Name="mydataset2">
> > <Fields>
> > <Field Name="EmployeeID">
> > <DataField>EmployeeID</DataField>
> > <rd:TypeName>System.Int32</rd:TypeName>
> > </Field>
> > </Fields>
> > <Query>
> > <DataSourceName>ds1</DataSourceName>
> > <CommandType>Text</CommandType>
> > <CommandText>SELECT DISTINCT EmployeeID FROM Employees
> > ORDER BY EmployeeID ASC</CommandText>
> > <rd:UseGenericDesigner>true</rd:UseGenericDesigner>
> > </Query>
> > </DataSet>
> > <DataSet Name="mydataset3">
> > <Fields>
> > <Field Name="CustomerID">
> > <DataField>CustomerID</DataField>
> > <rd:TypeName>System.String</rd:TypeName>
> > </Field>
> > </Fields>
> > <Query>
> > <DataSourceName>ds1</DataSourceName>
> > <CommandType>Text</CommandType>
> > <CommandText>SELECT DISTINCT CustomerID FROM Orders
> > WHERE EmployeeID = @.EmployeeIDParam ORDER BY CustomerID ASC</CommandText>
> > <rd:UseGenericDesigner>true</rd:UseGenericDesigner>
> > <QueryParameters>
> > <QueryParameter Name="@.EmployeeIDParam">
> > <Value>=Parameters!EmployeeIDParam.Value</Value>
> > </QueryParameter>
> > </QueryParameters>
> > </Query>
> > </DataSet>
> > </DataSets>
> > <Language>en-US</Language>
> > <RightMargin>1in</RightMargin>
> > <BottomMargin>1in</BottomMargin>
> > <TopMargin>1in</TopMargin>
> > <rd:SnapToGrid>true</rd:SnapToGrid>
> > <Width>5in</Width>
> > <LeftMargin>1in</LeftMargin>
> > <ReportParameters>
> > <ReportParameter Name="EmployeeID">
> > <DataType>Integer</DataType>
> > <DefaultValue>
> > <Values>
> > <Value>1</Value>
> > </Values>
> > </DefaultValue>
> > <ValidValues>
> > <DataSetReference>
> > <DataSetName>mydataset2</DataSetName>
> > <ValueField>EmployeeID</ValueField>
> > <LabelField>EmployeeID</LabelField>
> > </DataSetReference>
> > </ValidValues>
> > <Prompt>Employee ID :</Prompt>
> > </ReportParameter>
> > <ReportParameter Name="EmployeeIDParam">
> > <DataType>Integer</DataType>
> > <DefaultValue>
> > <Values>
> > <Value>=Parameters!EmployeeID.Value</Value>
> > </Values>
> > </DefaultValue>
> > <Prompt> </Prompt>
> > </ReportParameter>
> > <ReportParameter Name="CustomerIDParam">
> > <DataType>String</DataType>
> > <DefaultValue>
> > <Values>
> > <Value>VINET</Value>
> > </Values>
> > </DefaultValue>
> > <ValidValues>
> > <DataSetReference>
> > <DataSetName>mydataset3</DataSetName>
> > <ValueField>CustomerID</ValueField>
> > <LabelField>CustomerID</LabelField>
> > </DataSetReference>
> > </ValidValues>
> > <Prompt>Customer ID :</Prompt>
> > </ReportParameter>
> > </ReportParameters>
> > </Report>
> > --
> > | Thread-Topic: Dynamic Parameter
> > | thread-index: AcUFhs+wyP3Cs1ONTxSLxYdNcM59XQ==> > | X-WBNR-Posting-Host: 70.66.0.254
> > | From: "=?Utf-8?B?U0FjYW51Y2s=?=" <SAcanuck@.discussions.microsoft.com>
> > | Subject: Dynamic Parameter
> > | Date: Fri, 28 Jan 2005 14:15:01 -0800
> > | Lines: 12
> > | Message-ID: <AE5AB9C9-7340-4ED3-9EC6-3F5DB22834AA@.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.reportingsvcs
> > | NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.1.29
> > | Path: cpmsftngxa10.phx.gbl!TK2MSFTNGXA03.phx.gbl
> > | Xref: cpmsftngxa10.phx.gbl microsoft.public.sqlserver.reportingsvcs:41264
> > | X-Tomcat-NG: microsoft.public.sqlserver.reportingsvcs
> > |
> > | My DB has 3 tables Employee, Department, Job
> > |
> > | I want to create a report with two parameters.
> > |
> > | Parameter 1 Options: Employee, Department or Job
> > |
> > | Parameter 2 Options: When user selects Employee from parameter 1, all
> > | employee names will be made available to select in parameter 2, When
> > user
> > | selects department from parameter 1, all department names will be made
> > | available to select in parameter 2.
> > |
> > | How would one doe this? Any help is appreciated.
> > |
> >
> >|||Brad:
I copied the rdl into my designer anf get te following error:
Deserialization failed: The Report element was not found.
""Brad Syputa - MS"" wrote:
> I did this for a Northwind DB. Here is how my RDL looked. Multiple queries
> and data sets returned.
> I changed the names of my data source and data sets. It should still work
> against a Northwind DB.
> <?xml version="1.0" encoding="utf-8"?>
> <Report
> xmlns="http://schemas.microsoft.com/sqlserver/reporting/2003/10/reportdefini
> tion"
> xmlns:rd="">http://schemas.microsoft.com/SQLServer/reporting/reportdesigner">
> <DataSources>
> <DataSource Name="ds1">
> <rd:DataSourceID>2122d420-3823-467b-8d49-89744c792684</rd:DataSourceID>
> <ConnectionProperties>
> <DataProvider>SQL</DataProvider>
> <ConnectString>data source=servername;initial
> catalog=Northwind</ConnectString>
> </ConnectionProperties>
> </DataSource>
> </DataSources>
> <rd:ReportID>48c77212-85fb-46c9-9347-e0ecf74aa394</rd:ReportID>
> <Body>
> <ReportItems>
> <Textbox Name="textbox_2">
> <Style>
> <BackgroundColor>Yellow</BackgroundColor>
> <TextAlign>Left</TextAlign>
> <FontSize>9pt</FontSize>
> </Style>
> <Height>.5 in</Height>
> <Width>3 in</Width>
> <CanGrow>true</CanGrow>
> <Value>=Fields!TestResult.Value
> + "********Parameters CustomerIDParam Value: " +
> Parameters!CustomerIDParam.Value
> + "********Parameters EmployeeIDParam Value: " +
> Str(Parameters!EmployeeIDParam.Value)
> </Value>
> <Top>.5 in</Top>
> <Left>0 in</Left>
> </Textbox>
> <Textbox Name="textbox_1">
> <Style>
> <BackgroundColor>Red</BackgroundColor>
> <FontSize>14pt</FontSize>
> </Style>
> <Height>.5 in</Height>
> <Width>3 in</Width>
> <CanGrow>true</CanGrow>
> <Value>Test Result Below:</Value>
> <Top>0 in</Top>
> <Left>0 in</Left>
> </Textbox>
> </ReportItems>
> <Height>1.705in</Height>
> </Body>
> <rd:DrawGrid>true</rd:DrawGrid>
> <DataSets>
> <DataSet Name="mydataset">
> <Fields>
> <Field Name="TestResult">
> <DataField>TestResult</DataField>
> <rd:TypeName>System.String</rd:TypeName>
> </Field>
> <Field Name="CustomerID">
> <DataField>CustomerID</DataField>
> <rd:TypeName>System.String</rd:TypeName>
> </Field>
> <Field Name="EmployeeID">
> <DataField>EmployeeID</DataField>
> <rd:TypeName>System.Int32</rd:TypeName>
> </Field>
> </Fields>
> <Query>
> <DataSourceName>ds1</DataSourceName>
> <CommandType>Text</CommandType>
> <CommandText>SELECT * , 'Test Passed' as "TestResult" FROM Orders
> WHERE EmployeeID = @.EmployeeIDParam AND CustomerID => @.CustomerIDParam</CommandText>
> <rd:UseGenericDesigner>true</rd:UseGenericDesigner>
> <QueryParameters>
> <QueryParameter Name="@.EmployeeIDParam">
> <Value>=Parameters!EmployeeIDParam.Value</Value>
> </QueryParameter>
> <QueryParameter Name="@.CustomerIDParam">
> <Value>=Parameters!CustomerIDParam.Value</Value>
> </QueryParameter>
> </QueryParameters>
> </Query>
> </DataSet>
> <DataSet Name="mydataset2">
> <Fields>
> <Field Name="EmployeeID">
> <DataField>EmployeeID</DataField>
> <rd:TypeName>System.Int32</rd:TypeName>
> </Field>
> </Fields>
> <Query>
> <DataSourceName>ds1</DataSourceName>
> <CommandType>Text</CommandType>
> <CommandText>SELECT DISTINCT EmployeeID FROM Employees
> ORDER BY EmployeeID ASC</CommandText>
> <rd:UseGenericDesigner>true</rd:UseGenericDesigner>
> </Query>
> </DataSet>
> <DataSet Name="mydataset3">
> <Fields>
> <Field Name="CustomerID">
> <DataField>CustomerID</DataField>
> <rd:TypeName>System.String</rd:TypeName>
> </Field>
> </Fields>
> <Query>
> <DataSourceName>ds1</DataSourceName>
> <CommandType>Text</CommandType>
> <CommandText>SELECT DISTINCT CustomerID FROM Orders
> WHERE EmployeeID = @.EmployeeIDParam ORDER BY CustomerID ASC</CommandText>
> <rd:UseGenericDesigner>true</rd:UseGenericDesigner>
> <QueryParameters>
> <QueryParameter Name="@.EmployeeIDParam">
> <Value>=Parameters!EmployeeIDParam.Value</Value>
> </QueryParameter>
> </QueryParameters>
> </Query>
> </DataSet>
> </DataSets>
> <Language>en-US</Language>
> <RightMargin>1in</RightMargin>
> <BottomMargin>1in</BottomMargin>
> <TopMargin>1in</TopMargin>
> <rd:SnapToGrid>true</rd:SnapToGrid>
> <Width>5in</Width>
> <LeftMargin>1in</LeftMargin>
> <ReportParameters>
> <ReportParameter Name="EmployeeID">
> <DataType>Integer</DataType>
> <DefaultValue>
> <Values>
> <Value>1</Value>
> </Values>
> </DefaultValue>
> <ValidValues>
> <DataSetReference>
> <DataSetName>mydataset2</DataSetName>
> <ValueField>EmployeeID</ValueField>
> <LabelField>EmployeeID</LabelField>
> </DataSetReference>
> </ValidValues>
> <Prompt>Employee ID :</Prompt>
> </ReportParameter>
> <ReportParameter Name="EmployeeIDParam">
> <DataType>Integer</DataType>
> <DefaultValue>
> <Values>
> <Value>=Parameters!EmployeeID.Value</Value>
> </Values>
> </DefaultValue>
> <Prompt> </Prompt>
> </ReportParameter>
> <ReportParameter Name="CustomerIDParam">
> <DataType>String</DataType>
> <DefaultValue>
> <Values>
> <Value>VINET</Value>
> </Values>
> </DefaultValue>
> <ValidValues>
> <DataSetReference>
> <DataSetName>mydataset3</DataSetName>
> <ValueField>CustomerID</ValueField>
> <LabelField>CustomerID</LabelField>
> </DataSetReference>
> </ValidValues>
> <Prompt>Customer ID :</Prompt>
> </ReportParameter>
> </ReportParameters>
> </Report>
> --
> | Thread-Topic: Dynamic Parameter
> | thread-index: AcUFhs+wyP3Cs1ONTxSLxYdNcM59XQ==> | X-WBNR-Posting-Host: 70.66.0.254
> | From: "=?Utf-8?B?U0FjYW51Y2s=?=" <SAcanuck@.discussions.microsoft.com>
> | Subject: Dynamic Parameter
> | Date: Fri, 28 Jan 2005 14:15:01 -0800
> | Lines: 12
> | Message-ID: <AE5AB9C9-7340-4ED3-9EC6-3F5DB22834AA@.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.reportingsvcs
> | NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.1.29
> | Path: cpmsftngxa10.phx.gbl!TK2MSFTNGXA03.phx.gbl
> | Xref: cpmsftngxa10.phx.gbl microsoft.public.sqlserver.reportingsvcs:41264
> | X-Tomcat-NG: microsoft.public.sqlserver.reportingsvcs
> |
> | My DB has 3 tables Employee, Department, Job
> |
> | I want to create a report with two parameters.
> |
> | Parameter 1 Options: Employee, Department or Job
> |
> | Parameter 2 Options: When user selects Employee from parameter 1, all
> | employee names will be made available to select in parameter 2, When
> user
> | selects department from parameter 1, all department names will be made
> | available to select in parameter 2.
> |
> | How would one doe this? Any help is appreciated.
> |
>|||Please describe your exact requirement. Becouse your sample is to solve with
the description in the online docu. Isn't it?
"SAcanuck" wrote:
> I had a look at the reporting services books online and it had a description
> on how to use a basiv dynamic parameter...my requirement is a bit more
> advanced than the given example.
> "Dev Main" wrote:
> > It is not necessary to dive into this RDL code.
> >
> > Go to the online help from Reporting Services. There is a chapter Create
> > Report (or similare) and there is a description of using Parameters. On the
> > end of this article is your question answered in the best way.
> >
> >
> >
> > ""Brad Syputa - MS"" wrote:
> >
> > > I did this for a Northwind DB. Here is how my RDL looked. Multiple queries
> > > and data sets returned.
> > >
> > > I changed the names of my data source and data sets. It should still work
> > > against a Northwind DB.
> > >
> > > <?xml version="1.0" encoding="utf-8"?>
> > > <Report
> > > xmlns="http://schemas.microsoft.com/sqlserver/reporting/2003/10/reportdefini
> > > tion"
> > > xmlns:rd="">http://schemas.microsoft.com/SQLServer/reporting/reportdesigner">
> > > <DataSources>
> > > <DataSource Name="ds1">
> > >
> > > <rd:DataSourceID>2122d420-3823-467b-8d49-89744c792684</rd:DataSourceID>
> > > <ConnectionProperties>
> > > <DataProvider>SQL</DataProvider>
> > > <ConnectString>data source=servername;initial
> > > catalog=Northwind</ConnectString>
> > > </ConnectionProperties>
> > > </DataSource>
> > > </DataSources>
> > > <rd:ReportID>48c77212-85fb-46c9-9347-e0ecf74aa394</rd:ReportID>
> > > <Body>
> > > <ReportItems>
> > > <Textbox Name="textbox_2">
> > > <Style>
> > > <BackgroundColor>Yellow</BackgroundColor>
> > > <TextAlign>Left</TextAlign>
> > > <FontSize>9pt</FontSize>
> > > </Style>
> > > <Height>.5 in</Height>
> > > <Width>3 in</Width>
> > > <CanGrow>true</CanGrow>
> > > <Value>=Fields!TestResult.Value
> > > + "********Parameters CustomerIDParam Value: " +
> > > Parameters!CustomerIDParam.Value
> > > + "********Parameters EmployeeIDParam Value: " +
> > > Str(Parameters!EmployeeIDParam.Value)
> > > </Value>
> > > <Top>.5 in</Top>
> > > <Left>0 in</Left>
> > > </Textbox>
> > > <Textbox Name="textbox_1">
> > > <Style>
> > > <BackgroundColor>Red</BackgroundColor>
> > > <FontSize>14pt</FontSize>
> > > </Style>
> > > <Height>.5 in</Height>
> > > <Width>3 in</Width>
> > > <CanGrow>true</CanGrow>
> > > <Value>Test Result Below:</Value>
> > > <Top>0 in</Top>
> > > <Left>0 in</Left>
> > > </Textbox>
> > > </ReportItems>
> > > <Height>1.705in</Height>
> > > </Body>
> > > <rd:DrawGrid>true</rd:DrawGrid>
> > > <DataSets>
> > > <DataSet Name="mydataset">
> > > <Fields>
> > > <Field Name="TestResult">
> > > <DataField>TestResult</DataField>
> > > <rd:TypeName>System.String</rd:TypeName>
> > > </Field>
> > > <Field Name="CustomerID">
> > > <DataField>CustomerID</DataField>
> > > <rd:TypeName>System.String</rd:TypeName>
> > > </Field>
> > > <Field Name="EmployeeID">
> > > <DataField>EmployeeID</DataField>
> > > <rd:TypeName>System.Int32</rd:TypeName>
> > > </Field>
> > > </Fields>
> > > <Query>
> > > <DataSourceName>ds1</DataSourceName>
> > > <CommandType>Text</CommandType>
> > > <CommandText>SELECT * , 'Test Passed' as "TestResult" FROM Orders
> > > WHERE EmployeeID = @.EmployeeIDParam AND CustomerID => > > @.CustomerIDParam</CommandText>
> > > <rd:UseGenericDesigner>true</rd:UseGenericDesigner>
> > > <QueryParameters>
> > > <QueryParameter Name="@.EmployeeIDParam">
> > > <Value>=Parameters!EmployeeIDParam.Value</Value>
> > > </QueryParameter>
> > > <QueryParameter Name="@.CustomerIDParam">
> > > <Value>=Parameters!CustomerIDParam.Value</Value>
> > > </QueryParameter>
> > > </QueryParameters>
> > > </Query>
> > > </DataSet>
> > > <DataSet Name="mydataset2">
> > > <Fields>
> > > <Field Name="EmployeeID">
> > > <DataField>EmployeeID</DataField>
> > > <rd:TypeName>System.Int32</rd:TypeName>
> > > </Field>
> > > </Fields>
> > > <Query>
> > > <DataSourceName>ds1</DataSourceName>
> > > <CommandType>Text</CommandType>
> > > <CommandText>SELECT DISTINCT EmployeeID FROM Employees
> > > ORDER BY EmployeeID ASC</CommandText>
> > > <rd:UseGenericDesigner>true</rd:UseGenericDesigner>
> > > </Query>
> > > </DataSet>
> > > <DataSet Name="mydataset3">
> > > <Fields>
> > > <Field Name="CustomerID">
> > > <DataField>CustomerID</DataField>
> > > <rd:TypeName>System.String</rd:TypeName>
> > > </Field>
> > > </Fields>
> > > <Query>
> > > <DataSourceName>ds1</DataSourceName>
> > > <CommandType>Text</CommandType>
> > > <CommandText>SELECT DISTINCT CustomerID FROM Orders
> > > WHERE EmployeeID = @.EmployeeIDParam ORDER BY CustomerID ASC</CommandText>
> > > <rd:UseGenericDesigner>true</rd:UseGenericDesigner>
> > > <QueryParameters>
> > > <QueryParameter Name="@.EmployeeIDParam">
> > > <Value>=Parameters!EmployeeIDParam.Value</Value>
> > > </QueryParameter>
> > > </QueryParameters>
> > > </Query>
> > > </DataSet>
> > > </DataSets>
> > > <Language>en-US</Language>
> > > <RightMargin>1in</RightMargin>
> > > <BottomMargin>1in</BottomMargin>
> > > <TopMargin>1in</TopMargin>
> > > <rd:SnapToGrid>true</rd:SnapToGrid>
> > > <Width>5in</Width>
> > > <LeftMargin>1in</LeftMargin>
> > > <ReportParameters>
> > > <ReportParameter Name="EmployeeID">
> > > <DataType>Integer</DataType>
> > > <DefaultValue>
> > > <Values>
> > > <Value>1</Value>
> > > </Values>
> > > </DefaultValue>
> > > <ValidValues>
> > > <DataSetReference>
> > > <DataSetName>mydataset2</DataSetName>
> > > <ValueField>EmployeeID</ValueField>
> > > <LabelField>EmployeeID</LabelField>
> > > </DataSetReference>
> > > </ValidValues>
> > > <Prompt>Employee ID :</Prompt>
> > > </ReportParameter>
> > > <ReportParameter Name="EmployeeIDParam">
> > > <DataType>Integer</DataType>
> > > <DefaultValue>
> > > <Values>
> > > <Value>=Parameters!EmployeeID.Value</Value>
> > > </Values>
> > > </DefaultValue>
> > > <Prompt> </Prompt>
> > > </ReportParameter>
> > > <ReportParameter Name="CustomerIDParam">
> > > <DataType>String</DataType>
> > > <DefaultValue>
> > > <Values>
> > > <Value>VINET</Value>
> > > </Values>
> > > </DefaultValue>
> > > <ValidValues>
> > > <DataSetReference>
> > > <DataSetName>mydataset3</DataSetName>
> > > <ValueField>CustomerID</ValueField>
> > > <LabelField>CustomerID</LabelField>
> > > </DataSetReference>
> > > </ValidValues>
> > > <Prompt>Customer ID :</Prompt>
> > > </ReportParameter>
> > > </ReportParameters>
> > > </Report>
> > > --
> > > | Thread-Topic: Dynamic Parameter
> > > | thread-index: AcUFhs+wyP3Cs1ONTxSLxYdNcM59XQ==> > > | X-WBNR-Posting-Host: 70.66.0.254
> > > | From: "=?Utf-8?B?U0FjYW51Y2s=?=" <SAcanuck@.discussions.microsoft.com>
> > > | Subject: Dynamic Parameter
> > > | Date: Fri, 28 Jan 2005 14:15:01 -0800
> > > | Lines: 12
> > > | Message-ID: <AE5AB9C9-7340-4ED3-9EC6-3F5DB22834AA@.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.reportingsvcs
> > > | NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.1.29
> > > | Path: cpmsftngxa10.phx.gbl!TK2MSFTNGXA03.phx.gbl
> > > | Xref: cpmsftngxa10.phx.gbl microsoft.public.sqlserver.reportingsvcs:41264
> > > | X-Tomcat-NG: microsoft.public.sqlserver.reportingsvcs
> > > |
> > > | My DB has 3 tables Employee, Department, Job
> > > |
> > > | I want to create a report with two parameters.
> > > |
> > > | Parameter 1 Options: Employee, Department or Job
> > > |
> > > | Parameter 2 Options: When user selects Employee from parameter 1, all
> > > | employee names will be made available to select in parameter 2, When
> > > user
> > > | selects department from parameter 1, all department names will be made
> > > | available to select in parameter 2.
> > > |
> > > | How would one doe this? Any help is appreciated.
> > > |
> > >
> > >

Dynamic Page Breaks

How can I create dynamic page breaks based on a number of records I only want
to be displayed per page?To create a page break after a specified number of rows:
1. Select the table properties
2. Add a grouping
3. In the Expression field add the following:
=Ceiling(RowNumber(Nothing)/30)
4. Check the â'Page break at endâ' check box.
reeves
"Terry" wrote:
> How can I create dynamic page breaks based on a number of records I only want
> to be displayed per page?|||Thank you so kindly.
By the way, should the new page break group be added to the already existing
groups?
"Reeves Smith" wrote:
> To create a page break after a specified number of rows:
> 1. Select the table properties
> 2. Add a grouping
> 3. In the Expression field add the following:
> =Ceiling(RowNumber(Nothing)/30)
> 4. Check the â'Page break at endâ' check box.
> reeves
> "Terry" wrote:
> > How can I create dynamic page breaks based on a number of records I only want
> > to be displayed per page?|||Terry,
Yes you need to add a group even if groups already exist. Where it is placed
might get a little tricky and need to be played with.
I got this info from a technical article: Report Design: Best Practices and
Guidelines
but it looks like this article got updated to: Report Design Tips and Tricks
(http://msdn2.microsoft.com/en-us/library/bb395166(sql.90).aspx) and there
looks to be another way in the new article to do what your after.
Here is the site for some great articles:
http://msdn2.microsoft.com/en-us/library/aa496080.aspx
The Chart one is VERY good.
Reeves
"Terry" wrote:
> Thank you so kindly.
> By the way, should the new page break group be added to the already existing
> groups?
>
> "Reeves Smith" wrote:
> > To create a page break after a specified number of rows:
> >
> > 1. Select the table properties
> > 2. Add a grouping
> > 3. In the Expression field add the following:
> >
> > =Ceiling(RowNumber(Nothing)/30)
> >
> > 4. Check the â'Page break at endâ' check box.
> >
> > reeves
> >
> > "Terry" wrote:
> >
> > > How can I create dynamic page breaks based on a number of records I only want
> > > to be displayed per page?|||I have tried this on multiple occassions and I always get this error message...
[rsInvalidGroupExpressionScope] A group expression for the table â'table1â'
uses the RowNumber function with a scope parameter that is not valid. When
used in a group expression, the value of the scope parameter of RowNumber
must equal the name of the group directly containing the current group.
Build complete -- 1 errors, 0 warnings
I'm sure there is something else that i am missing...
Any suggestions will be greatly appreciated.
--
CipherTeKST
MCSE: Security 2003, CCNA, Security+
"Reeves Smith" wrote:
> To create a page break after a specified number of rows:
> 1. Select the table properties
> 2. Add a grouping
> 3. In the Expression field add the following:
> =Ceiling(RowNumber(Nothing)/30)
> 4. Check the â'Page break at endâ' check box.
> reeves
> "Terry" wrote:
> > How can I create dynamic page breaks based on a number of records I only want
> > to be displayed per page?

Wednesday, March 21, 2012

dynamic matrix reports

Hello,
Is it possible to create a report which allows users to select the
fields
for the matrix in a report. To explain in detail, can we allow the
users to
select the X and Y axis for a matrix in a report?
For ex., there is a report containing a matrix which shows the total
sales(
data cell) by month (X axis) and by Rep( Y axis). Can we have some
option
so that if the users select Year as the X axis and Company as the Y
axis
then they can view the same report but by company and Year instead of
Month and Rep?
Regards
Jaideepcertainly.
Just use a switch statement or iif statement for the values for the row
and column groups:
switch(parameters!group.value = 'x', fields!month.value,
parameters!group.value = 'y', fields!year.value)
or
iif(parameters!group.value = 'x', fields!month.value,
fields!year.value)
jai wrote:
> Hello,
> Is it possible to create a report which allows users to select the
> fields
> for the matrix in a report. To explain in detail, can we allow the
> users to
> select the X and Y axis for a matrix in a report?
>
> For ex., there is a report containing a matrix which shows the total
> sales(
> data cell) by month (X axis) and by Rep( Y axis). Can we have some
> option
> so that if the users select Year as the X axis and Company as the Y
> axis
> then they can view the same report but by company and Year instead of
> Month and Rep?
>
> Regards
> Jaideep

Dynamic Login & User Creation

Hello. I'm trying to create a new login and username inside a trigger using variables.

This code works:

create login testUserName with password = 'testPassword'

The problem comes when I try to use variables for the username and password like this.

create login @.username with password = @.password

Does anybody know how to get around this problem?

BTW, the error message it gives is this, but I really doubt that semicolons have anything to do with it. If I literally type my data in the create login call it works fine, but when I use variables it doesn't.

Msg 102, Level 15, State 1, Line 14

Incorrect syntax near '@.username'.

Msg 319, Level 15, State 1, Line 14

Incorrect syntax near the keyword 'with'. If this statement is a common table expression or an xmlnamespaces clause, the previous statement must be terminated with a semicolon.

SQL Server doesn't allow you to specify variables in most DDL statements. So the only way is to form the CREATE LOGIN statement as a string and execute it using dynamic SQL. See the EXECUTE topic in Books Online for more details on how to execute SQL statements dynamically.|||


This doesn′t work unless you wrap it in dynamic SQL:

DECLARE @.SQLString VARCHAR(400)
SET @.SQLString = 'CREATE LOGIN ' + @.USERNAME + WITH PASSWORD ' + @.PASSWORD
EXEC(@.SQLSTRING)


HTH, Jens Suessmeyer.


http://www.sqlserver2005.de


|||

Thanks a lot! Just in case anybody else has this problem, here's some code that does what I wanted.

declare @.USERNAME varchar(50);

declare @.PASSWORD varchar(50);

set @.USERNAME = 'testUserName2';

set @.PASSWORD = 'testPassword';

DECLARE @.SQLString VARCHAR(400)

SET @.SQLString = 'CREATE LOGIN ' + @.USERNAME + ' WITH PASSWORD = ' + CHAR(39) + @.PASSWORD + CHAR(39)

EXEC(@.SQLSTRING)

|||

You need to protect the dynamic SQL against SQL injection attacks. So you need to quote the login name which is an identifier otherwise potentially someone could provide a malicious login name which can be used to do attack the database. The password part is hard to protect since it is just a string. So you will have to validate it for certain characters in the front-end.

declare @.USERNAME varchar(50);

declare @.PASSWORD varchar(50);

set @.USERNAME = quotename('testUserName2'); -- Use quotename to form the identifier

set @.PASSWORD = 'testPassword';

DECLARE @.SQLString VARCHAR(400)

SET @.SQLString = 'CREATE LOGIN ' + @.USERNAME + ' WITH PASSWORD = ' + CHAR(39) + @.PASSWORD + CHAR(39)

EXEC(@.SQLSTRING)

|||Thanks for the tip. We're currently protecting against it on the front end but I recently heard there are steps I can take in the database for protection, so I'll have to look into that. Thanks.

Dynamic List

Is there a way to create a dynamic list? I have two variables I want to combine with two constants to create a list of 4 entries that I could run through a loop.You can use a script task to populate an object variable with an array. Then you can use the Foreach from Variable Enumerator to loop through the array. The script to populate the array could look similar to this (using your variables in place of some of the constants).

Code Snippet

Public Sub Main()
Dim LoopItems(3) As String
LoopItems.SetValue("One", 0)
LoopItems.SetValue("Two", 1)
LoopItems.SetValue("Three", 2)
LoopItems.SetValue("Four", 3)
Dts.Variables("LoopItems").Value = LoopItems
Dts.TaskResult = Dts.Results.Success
End Sub

Alternatively, you could also use an Execute SQL task with a UNION statement to populate a object variable with a recordset of your values and then use the Foreach ADO Enumerator. You would create your SQL statement using an expression-based variable.

|||

Thanks. I think creating a recordset in script might be my only alternative. I needed two columns for the four entries and For Each from a variable seems to only work with a single column. My problem was that I had two locations each of which had two types of files that needed deleting. The locations had to come from variables while the file types were constants. The entire solution in .Net was 7 more lines of code than you listed, I was just hoping to stay out of code.

Public Sub Main()

Dim directoryList As New List(Of String)

Dim patternList As New List(Of String)

directoryList.Add(CStr(Dts.Variables("principalLocation").Value))

directoryList.Add(CStr(Dts.Variables("mirrorLocation").Value))

patternList.Add("*.bak")

patternList.Add("*.trn")

For Each directoryItem As String In directoryList

For Each patternItem As String In patternList

For Each file As String In Directory.GetFiles(directoryItem, patternItem)

System.IO.File.Delete(file)

Next

Next

Next

Dts.TaskResult = Dts.Results.Success

End Sub

The problem is mostly that I can't have an empty directory or my daily maintenance will remove the directory. So I have a file in the directory called keepthis.txt. Another pure SSIS solution I guess would be to Delete the contents of the directory and then copy a keepthis.txt from somewhere else into that directory, I'd just have hope that the daily maintenance would never run at the same time this ran, something I'd rather not hope for with 12 people that can manually run this, usually under pressure.

Thanks for the solution though, I found the way you set array variables interesting, I hadn't seen that before!

Monday, March 19, 2012

Dynamic Index Drop and Create

I am working on a data warehouse that is SQL Server 2000 based and what
I need to do is create two stored procs that do the following psuedo
code. I can write it myself but if someone has already written it then
why write it again or if you know of solutions that are close to what I
want that would be a good start. The reason that these need to be in
two seperate procs is that I want to seperate out the Drop and Creates
from the stored procedure that is loading the table. Instead of
hardcoding the drops and creates I want this procedure to be more
dynamic so that as we add indexes for tunning we don't have to maintain
our stored procedures.
proc_DropIndexes @.DatabaseName, @.TableName
- Write all necessary current index information to a work table for
@.DatabaseName and @.TableName to allow for recreation
- Drop all current indexes for @.DatabaseName and @.TableName
proc_CreateIndexes @.DatabaseName, @.TableName
- Read all necessary current index information from a work table for
@.DatabaseName and @.TableName to allow for recreation
- Create all indexes for @.DatabaseName and @.TableName
Thanks,
SpencerThe following appear to be good starts...
http://www.code-magazine.com/articl...b9cc0d4526e1913

Dynamic Index Drop and Create

I am working on a data warehouse that is SQL Server 2000 based and what
I need to do is create two stored procs that do the following psuedo
code. I can write it myself but if someone has already written it then
why write it again or if you know of solutions that are close to what I
want that would be a good start. The reason that these need to be in
two seperate procs is that I want to seperate out the Drop and Creates
from the stored procedure that is loading the table. Instead of
hardcoding the drops and creates I want this procedure to be more
dynamic so that as we add indexes for tunning we don't have to maintain
our stored procedures.
proc_DropIndexes @.DatabaseName, @.TableName
- Write all necessary current index information to a work table for
@.DatabaseName and @.TableName to allow for recreation
- Drop all current indexes for @.DatabaseName and @.TableName
proc_CreateIndexes @.DatabaseName, @.TableName
- Read all necessary current index information from a work table for
@.DatabaseName and @.TableName to allow for recreation
- Create all indexes for @.DatabaseName and @.TableName
Thanks,
SpencerThe following appear to be good starts...
http://www.code-magazine.com/articleprint.aspx?quickid=0301101&printmode=true
http://groups.google.com/group/microsoft.public.sqlserver.server/browse_thread/thread/1f4dd406fa18d676/8b9cc0d4526e1913?lnk=st&q=scripting+sql+server+indexes+create+drop&rnum=16&hl=en#8b9cc0d4526e1913