Showing posts with label named. Show all posts
Showing posts with label named. Show all posts

Friday, March 30, 2012

passing parameter

I have a stored procedure named "processInventory" like the following.
Depending on the passed in parameters, I would like to add a WHERE
clause for "select" action. For example, if any varchar type of
parameter is passed in, the where clause would use "LIKE" operator. For
example, "Select * from Main where [s/n] like @.Serial. All other types
will use "=" operator. For example, "Select * from Main where MAKE =
@.Make and Type = @.type".
How could this be achieved? Thanks.

CREATE PROCEDURE processInventory
@.Action varchar(7),
@.ControlNumber int = null,
@.AssetTag int = null,
@.Serial varchar(50) = null,
@.Description varchar(50) = null,
@.Make int = null,
@.Type int = null,
@.Model int = null,
@.Status int = null,
@.Networked bit = null,
@.LoginName varchar(50) = null,
@.Shared bit = null,
@.Org varchar(15) = null,
@.RecordDate datetime = null,
@.LastUpdate datetime = null,
@.ManufactureDate datetime = null,
@.Comment ntext = null

AS

declare @.processError int
set @.processError = 0

if @.Action = 'Select' goto selectInventory
else
If @.Action = 'Update'
begin
if @.ControlNumber = null return(1) --Required parameter value not
specified
else
goto updateInventory
end
else
if @.Action = 'Insert'
begin
if @.Serial = null return(1) --Required parameter value not
specified
else
goto InsertInventory
end
else
if @.Action = 'Delete'
begin
if @.ControlNumber = null return(1) --Required parameter value
not specified
else goto deleteInventory
end

selectInventory:
if @.Serial <> null
begin
select * from Main where [S/N] like @.Serial
if @.@.Error<>0
begin
set @.processError = @.@.Error
return @.processError
end
end
else
if @.ControlNumber <> null
begin
select * from Main where ControlNumber = @.ControlNumber
if @.@.Error <>0
begin
set @.processError = @.@.Error
return @.processError
end
end
else
select top 100* from Main

updateInventory:
update MAIN
set [Org Asset Tag] = @.AssetTag, [S/N] = @.Serial, [Description]
= @.Description, Make = @.Make, Type = @.Type,
Model = @.Model, Status = @.Status, Networked = @.Networked,
LoginName = @.LoginName, Shared = @.Shared,
Org = @.Org, [Date Of Record] = @.RecordDate, [Date Last
Updated] = @.LastUpdate, [Manuf Date] = @.ManufactureDate,
Comments = @.Comment
where ControlNumber = @.ControlNumber
if @.@.ERROR <> 0
begin
set @.processError = @.@.ERROR
return @.processError
end
else
return(0) -- successful update

insertInventory:
insert MAIN([Org Asset Tag], [S/N], [Description], Make, Type,
Model, Status, Networked, LoginName, Shared,
Org, [Date Of Record], [Date Last Updated], [Manuf
Date],Comments)
values(@.AssetTag, @.Serial, @.Description, @.Make, @.Type, @.Model,
@.Status, @.Networked, @.LoginName, @.Shared,
@.Org, @.RecordDate, @.LastUpdate, @.ManufactureDate,
@.Comment)
if @.@.ERROR <> 0
begin
set @.processError = @.@.ERROR
return @.processError
end
else return(0) -- successful insert

deleteInventory:
delete MAIN where ControlNumber = @.ControlNumber
if @.@.ERROR <> 0
begin
set @.processError = @.@.ERROR
return @.processError
end
else return(0) -- successful delete
GOFirst, I would suggest that you not lump all of your actions together
in one stored procedure; you will suffer from a performance impact,
because SQL Server will be forced to recompile your procedure every
time it runs (for SELECT, UPDATE, or DELETE). This is never a good
idea.

That being said, you could set the default value of the parameter you
wish to use wildcards on as a wildcard ('%'); later, in the body of the
stored procedure, add a wildcard character to the value before you use
it in the query. A simple example is below:

CREATE PROC procTestWildcard @.Param varchar(10) = '%' AS

SET @.Param = @.Param + '%'

SELECT Column
FROM Table
WHERE Column Like @.Param

--

Running the following

exec procWildCardTest

will return all of the data in your table since you've essentially run
the statement

SELECT Column
FROM Table
WHERE Column Like '%%'

The statement

exec procWildCardTest 'S'

will return all of the data in your table that starts with the letter
'S', since the SQL statement is now interpreted as

SELECT Column
FROM Table
WHERE Column Like 'S%'

HTH,
Stu|||Thanks for your suggestion. As you can see, I have more than one
parameter that might be passed into the proc. How do I dermine which
one is passed in? If I use IF..ELSE, there would be many combination
of parameters. I don't think SQL2000 allow concation of partitial
statments, so each combination need to be dealt with like
IF @.Make <> NULL
SELECT COL1, COL2 FROM TABLE WHERE MAKE LIKE @.Make
ELSE
IF @.Make <> NULL AND @.Model <> NULL
SELECT COL1, COL2 FROM TABLE WHERE MAKE LIKE @.Make and MODEL LIKE
@.Model
ELSE
other paramter combination|||The suggestion I gave above will work for any number of paramater
combinations. Not the most effecient way, but it will work.

CREATE PROC procTestParams (@.Make varchar(10) = '%', @.Model varchar(10)
= '%') AS

SET @.Make = @.Make+'%'
SET @.Model = @.Model+'%'

SELECT COL1, COL2
FROM TABLE
WHERE MAKE LIKE @.Make
and MODEL LIKE @.Model

Another way to do this is to build your SQL string dynamically and use
sp_executeSQL

CREATE PROC procTestParams (@.Make varchar(10) =NULL, @.Model
varchar(10) = NULL) AS

DECLARE @.SQL nvarchar(4000)

/*Return all records by default; need a basic true WHERE condition so
that you can
append AND's to it as needed*/

SET @.SQL = 'SELECT COL1, COL2 FROM TABLE WHERE 1=1 '

IF @.Make IS NOT NULL
SET @.SQL =@.SQL + ' AND Make LIKE @.Make ' --make sure that you are
passing wildcards if needed

IF @.Model IS NOT NULL
SET @.SQL =@.SQL + ' AND Model LIKE @.Model '

exec sp_executeSQL @.SQL, N'@.Make varchar(10), @.Model varchar(10)',
@.Make, @.Model

You'll just have to play around with it to see which is more effecient;
the first version will basically run a search against all parameters,
looking for wildcards (any data) on the columns you don't specify a
value for, whereas the second version will dynamically build a SQL
statement to be executed against only those columns you supply a
parameter for. The effeciency of either approach is going to be
affected by the number and atype of indexes on your table, and the
amount of data to be returned.

Hope that clarifies.

Stu|||[posted and mailed, please reply in news]

js (androidsun@.yahoo.com) writes:
> I have a stored procedure named "processInventory" like the following.
> Depending on the passed in parameters, I would like to add a WHERE
> clause for "select" action. For example, if any varchar type of
> parameter is passed in, the where clause would use "LIKE" operator. For
> example, "Select * from Main where [s/n] like @.Serial. All other types
> will use "=" operator. For example, "Select * from Main where MAKE =
> @.Make and Type = @.type".
> How could this be achieved? Thanks.

I have a longer article on the topic on
http://www.sommarskog.se/dyn-search.html.

Since you are into UPDATE, I would careful with using dynamic SQL
because of the permissions issues.

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp

Wednesday, March 28, 2012

Passing Multivalued Parameters through URL interface

Hi,
We are trying to generate report by passing parameter values through url
In our report, we have a multivalued parameter named "ABC", having values
say, val1, val2 and val3.
When try to generate the report with parameter ABC having values as val1 and
val2 using the url mentioned below, we find that the values are not selected
and report is not rendered.
http://<machinename>/ReportServer/Pages/ReportViewer.aspx?<reportpath>0&rs:Command=Render¶meter=val1,val2
This is working fine for singlevalued parameters.
Thanks in advanced,
Sumit PilankarA comma separated list of values in the QueryString doesn't do it.
I know one way to do it, but it isn't real elegant.
rather than this:
¶m=val1,val2,val3
you do this:
¶m=val1¶m=val2¶m=val3
Andy Potter|||how about UrlEncode(val1,val2,val3)?|||Thank you very much for the suggestion, it worked for me.:)
"Potter" <drewpotter@.gmail.com> wrote in message
news:1137178379.083160.191810@.o13g2000cwo.googlegroups.com...
>A comma separated list of values in the QueryString doesn't do it.
> I know one way to do it, but it isn't real elegant.
> rather than this:
> ¶m=val1,val2,val3
> you do this:
> ¶m=val1¶m=val2¶m=val3
> Andy Potter
>|||Thanks for the help.
UrlEncode is required, but we need to form the URL as Andy Potter said.
"Q. John Chen" <qjchen@.email.com> wrote in message
news:1137183444.756449.131090@.g43g2000cwa.googlegroups.com...
> how about UrlEncode(val1,val2,val3)?
>

Friday, March 23, 2012

Passing Date Variables

I am a newbie and need help. I am creating an intranet site for my company
and my SQL2000 database has a column named transdate. I want to provide the
user with the ability to run a canned report depending on a date range
entered in a web form (Start Date / End Date).
How would I pass these form entries to my SQL select statement? I am using
ASP VBScript
I'm thinking...
Select *
from DB where transdate >= ' and transdate <= '
Your help is greatly appreciated!!!
Message posted via webservertalk.com
http://www.webservertalk.com/Uwe/Forum...amming/200606/1> How would I pass these form entries to my SQL select statement? I am using
> ASP VBScript
You can use a parameterized SQL statement, specifying '?' as parameter
markers:
Set command = CreateObject("ADODB.Command")
command.ActiveConnection = myConnection
command.CommandText = "SELECT * FROM MyTable WHERE transdate >= ? AND
transdate <= ?"
Set fromDateParameter = command.CreateParameter( _
"@.fromDate", adDate, adParamInput)
command.Parameters.Append fromDateParameter
fromDateParameter.Value = "2006-05-01"
Set toDateParameter = command.CreateParameter( _
"@.toDateParameter", adDate, adParamInput)
command.Parameters.Append toDateParameter
toDateParameter.Value = "2006-05-31"
Hope this helps.
Dan Guzman
SQL Server MVP
"Chamark via webservertalk.com" <u21870@.uwe> wrote in message
news:615867ef9c88a@.uwe...
>I am a newbie and need help. I am creating an intranet site for my company
> and my SQL2000 database has a column named transdate. I want to provide
> the
> user with the ability to run a canned report depending on a date range
> entered in a web form (Start Date / End Date).
> How would I pass these form entries to my SQL select statement? I am using
> ASP VBScript
> I'm thinking...
> Select *
> from DB where transdate >= ' and transdate <= '
> Your help is greatly appreciated!!!
> --
> Message posted via webservertalk.com
> http://www.webservertalk.com/Uwe/Forum...amming/200606/1|||Thanks Dan, I'll give it a shot
Dan Guzman wrote:
>You can use a parameterized SQL statement, specifying '?' as parameter
>markers:
>Set command = CreateObject("ADODB.Command")
>command.ActiveConnection = myConnection
>command.CommandText = "SELECT * FROM MyTable WHERE transdate >= ? AND
>transdate <= ?"
>Set fromDateParameter = command.CreateParameter( _
> "@.fromDate", adDate, adParamInput)
>command.Parameters.Append fromDateParameter
>fromDateParameter.Value = "2006-05-01"
>Set toDateParameter = command.CreateParameter( _
> "@.toDateParameter", adDate, adParamInput)
>command.Parameters.Append toDateParameter
>toDateParameter.Value = "2006-05-31"
>
>[quoted text clipped - 11 lines]
Message posted via http://www.webservertalk.com|||Obviously I am not advanced enough to get this? I need to pass the dates
from my Web form to the embedded SQL statement in Dreamweaver. I am using
multiple recordsets that require these same date ranges. In ACCESS it is eas
y
because you can create the form and reference it. Is there anything like thi
s
in SQL?
Dan Guzman wrote:
>You can use a parameterized SQL statement, specifying '?' as parameter
>markers:
>Set command = CreateObject("ADODB.Command")
>command.ActiveConnection = myConnection
>command.CommandText = "SELECT * FROM MyTable WHERE transdate >= ? AND
>transdate <= ?"
>Set fromDateParameter = command.CreateParameter( _
> "@.fromDate", adDate, adParamInput)
>command.Parameters.Append fromDateParameter
>fromDateParameter.Value = "2006-05-01"
>Set toDateParameter = command.CreateParameter( _
> "@.toDateParameter", adDate, adParamInput)
>command.Parameters.Append toDateParameter
>toDateParameter.Value = "2006-05-31"
>
>[quoted text clipped - 11 lines]
Message posted via http://www.webservertalk.com|||> Obviously I am not advanced enough to get this? I need to pass the dates
> from my Web form to the embedded SQL statement in Dreamweaver. I am using
> multiple recordsets that require these same date ranges. In ACCESS it is
> easy
> because you can create the form and reference it. Is there anything like
> this
> in SQL?
SQL Server is basically just the back-end database engine. Unlike SQL
Server, Access also includes an IDE so that you can develop a 'rich client'
GUI for your users. The Access database engine isn't a client/server DBMS
because Access runs in the client process and, in the case of a multi-user
application, the Access database file is shared among multiple Access
instances. With SQL Server, it is the database engine is shared and only
that SQL Server instance accesses the database files.
I know next to nothing about Dreamweaver so I can't provide detailed help.
I don't know what an 'embedded SQL statement in Dreamweaver' is. I assume
this part of server-side code (ASP or ASP.NET) that is generated by the
Dreamweaver IDE. I would expect that the IDE would provide some method to
parameterize the SQL statement, map to your form variables and associate
with a SQL Server database connection.
don't know if this will help but below is an ASP VBScript snippet that can
execute a SQL statement based on the date range. I would expect Dreamweaver
would generate something similar.
<!-- include ADO constants -->
<!-- METADATA
TYPE="typelib"
UUID="00000200-0000-0010-8000-00AA006D2EA4"
-->
<%
Set connection = CreateObject("ADODB.Connection")
connection,Open "Provider=SQLOLEDB;Data Source=MyDbServer;Integrated
Security=SSPI"
Set command = CreateObject("ADODB.Command")
command.ActiveConnection = myConnection
command.CommandText = "SELECT * FROM MyTable " & _
"WHERE transdate >= ? AND transdate <= ?"
Set fromDateParameter = command.CreateParameter( _
"@.fromDate", adDate, adParamInput)
command.Parameters.Append fromDateParameter
fromDateParameter.Value = Request("fromDate")
Set toDateParameter = command.CreateParameter( _
"@.toDateParameter", adDate, adParamInput)
command.Parameters.Append toDateParameter
toDateParameter.Value = Request("toDate")
Set results = command.Execute
While results.EOF = False
'process row here
results.MoveNext
Loop
results.Close
connection,Close
&>
Hope this helps.
Dan Guzman
SQL Server MVP
"Chamark via webservertalk.com" <u21870@.uwe> wrote in message
news:61bd9dcc71568@.uwe...
> Obviously I am not advanced enough to get this? I need to pass the dates
> from my Web form to the embedded SQL statement in Dreamweaver. I am using
> multiple recordsets that require these same date ranges. In ACCESS it is
> easy
> because you can create the form and reference it. Is there anything like
> this
> in SQL?
> Dan Guzman wrote:
> --
> Message posted via http://www.webservertalk.comsql

Monday, March 12, 2012

Passing a multi-value parameter to a Subreport

How do I pass a multi-value parameter to a subreport?
For example, if my main report has a multi-value parameter named @.p1 and my
subreport's dataset is generated by SQL
SELECT a,b FROM MyTable WHERE a IN (@.LongList)
how do I then pass the user-selected @.p1 values from the main report to the
@.LongList parameter in the subreport?
I tried specifying JOIN(@.P1.Value,",") for a parameter value, but it did not
work.
Any help/suggestions will be appreciated. Thanks in advanceThis is just a guess based on what I know is going on behind the covers but
try the following. In your subreport make the Report Parameter @.LongList a
multi-value parameter. Test the subreport stand alone and make sure it
works. Then drop the subreport into your main report, right mouse click on
it, parameters and map the report parameter from the subreport to the report
parameter from the main report. You should not have to do anything fancy.
Let me know if it works.
Bruce Loehle-Conger
MVP SQL Server Reporting Services
"isaak" <isaak.peretsman at usa.dupont.com (no spam)> wrote in message
news:4785EFE4-9436-4715-8AA4-A57CC8E9AC78@.microsoft.com...
> How do I pass a multi-value parameter to a subreport?
> For example, if my main report has a multi-value parameter named @.p1 and
> my
> subreport's dataset is generated by SQL
> SELECT a,b FROM MyTable WHERE a IN (@.LongList)
> how do I then pass the user-selected @.p1 values from the main report to
> the
> @.LongList parameter in the subreport?
> I tried specifying JOIN(@.P1.Value,",") for a parameter value, but it did
> not
> work.
> Any help/suggestions will be appreciated. Thanks in advance
>|||Bruce,
This works. Once again - thanks for your help.
Isaak
"Bruce L-C [MVP]" wrote:
> This is just a guess based on what I know is going on behind the covers but
> try the following. In your subreport make the Report Parameter @.LongList a
> multi-value parameter. Test the subreport stand alone and make sure it
> works. Then drop the subreport into your main report, right mouse click on
> it, parameters and map the report parameter from the subreport to the report
> parameter from the main report. You should not have to do anything fancy.
> Let me know if it works.
>
> --
> Bruce Loehle-Conger
> MVP SQL Server Reporting Services
> "isaak" <isaak.peretsman at usa.dupont.com (no spam)> wrote in message
> news:4785EFE4-9436-4715-8AA4-A57CC8E9AC78@.microsoft.com...
> > How do I pass a multi-value parameter to a subreport?
> >
> > For example, if my main report has a multi-value parameter named @.p1 and
> > my
> > subreport's dataset is generated by SQL
> >
> > SELECT a,b FROM MyTable WHERE a IN (@.LongList)
> >
> > how do I then pass the user-selected @.p1 values from the main report to
> > the
> > @.LongList parameter in the subreport?
> >
> > I tried specifying JOIN(@.P1.Value,",") for a parameter value, but it did
> > not
> > work.
> >
> > Any help/suggestions will be appreciated. Thanks in advance
> >
>
>|||Appreciate you getting back and letting me know the result. As I said it was
a guess on my part.
--
Bruce Loehle-Conger
MVP SQL Server Reporting Services
"isaak" <isaak.peretsman at usa.dupont.com (no spam)> wrote in message
news:D71C1BB0-7AB0-4CFF-BD5F-D6B789D59906@.microsoft.com...
> Bruce,
> This works. Once again - thanks for your help.
> Isaak
> "Bruce L-C [MVP]" wrote:
>> This is just a guess based on what I know is going on behind the covers
>> but
>> try the following. In your subreport make the Report Parameter @.LongList
>> a
>> multi-value parameter. Test the subreport stand alone and make sure it
>> works. Then drop the subreport into your main report, right mouse click
>> on
>> it, parameters and map the report parameter from the subreport to the
>> report
>> parameter from the main report. You should not have to do anything fancy.
>> Let me know if it works.
>>
>> --
>> Bruce Loehle-Conger
>> MVP SQL Server Reporting Services
>> "isaak" <isaak.peretsman at usa.dupont.com (no spam)> wrote in message
>> news:4785EFE4-9436-4715-8AA4-A57CC8E9AC78@.microsoft.com...
>> > How do I pass a multi-value parameter to a subreport?
>> >
>> > For example, if my main report has a multi-value parameter named @.p1
>> > and
>> > my
>> > subreport's dataset is generated by SQL
>> >
>> > SELECT a,b FROM MyTable WHERE a IN (@.LongList)
>> >
>> > how do I then pass the user-selected @.p1 values from the main report to
>> > the
>> > @.LongList parameter in the subreport?
>> >
>> > I tried specifying JOIN(@.P1.Value,",") for a parameter value, but it
>> > did
>> > not
>> > work.
>> >
>> > Any help/suggestions will be appreciated. Thanks in advance
>> >
>>|||Isaak,
Since yours works, may I ask you a question?
In my main report, the parameter that I want to pass to subreport is
"Fields!CallID.value", so I right-click the subreport in main report,
properties, parameter, parameter name is "CallID", parameter value is
"Fields!CallID.value". In my subreport, my sql query is (In subreport)
select Tracker, EntryDate, EntryText from dbo.Journal
where CallID = @.CallID
I go to paramters tab, I see the name is "@.CallID" and value ="Parameters!CallID.value".
when I run from main report, there is no error but subreport is not showing
in the main report. Do I miss something here? Thanks!
Henry
"isaak" wrote:
> Bruce,
> This works. Once again - thanks for your help.
> Isaak
> "Bruce L-C [MVP]" wrote:
> > This is just a guess based on what I know is going on behind the covers but
> > try the following. In your subreport make the Report Parameter @.LongList a
> > multi-value parameter. Test the subreport stand alone and make sure it
> > works. Then drop the subreport into your main report, right mouse click on
> > it, parameters and map the report parameter from the subreport to the report
> > parameter from the main report. You should not have to do anything fancy.
> >
> > Let me know if it works.
> >
> >
> > --
> > Bruce Loehle-Conger
> > MVP SQL Server Reporting Services
> >
> > "isaak" <isaak.peretsman at usa.dupont.com (no spam)> wrote in message
> > news:4785EFE4-9436-4715-8AA4-A57CC8E9AC78@.microsoft.com...
> > > How do I pass a multi-value parameter to a subreport?
> > >
> > > For example, if my main report has a multi-value parameter named @.p1 and
> > > my
> > > subreport's dataset is generated by SQL
> > >
> > > SELECT a,b FROM MyTable WHERE a IN (@.LongList)
> > >
> > > how do I then pass the user-selected @.p1 values from the main report to
> > > the
> > > @.LongList parameter in the subreport?
> > >
> > > I tried specifying JOIN(@.P1.Value,",") for a parameter value, but it did
> > > not
> > > work.
> > >
> > > Any help/suggestions will be appreciated. Thanks in advance
> > >
> >
> >
> >|||Issak,
I got it to work. Thanks!
Henry
"Henry Chen" wrote:
> Isaak,
> Since yours works, may I ask you a question?
> In my main report, the parameter that I want to pass to subreport is
> "Fields!CallID.value", so I right-click the subreport in main report,
> properties, parameter, parameter name is "CallID", parameter value is
> "Fields!CallID.value". In my subreport, my sql query is (In subreport)
> select Tracker, EntryDate, EntryText from dbo.Journal
> where CallID = @.CallID
> I go to paramters tab, I see the name is "@.CallID" and value => "Parameters!CallID.value".
> when I run from main report, there is no error but subreport is not showing
> in the main report. Do I miss something here? Thanks!
> Henry
> "isaak" wrote:
> > Bruce,
> >
> > This works. Once again - thanks for your help.
> >
> > Isaak
> >
> > "Bruce L-C [MVP]" wrote:
> >
> > > This is just a guess based on what I know is going on behind the covers but
> > > try the following. In your subreport make the Report Parameter @.LongList a
> > > multi-value parameter. Test the subreport stand alone and make sure it
> > > works. Then drop the subreport into your main report, right mouse click on
> > > it, parameters and map the report parameter from the subreport to the report
> > > parameter from the main report. You should not have to do anything fancy.
> > >
> > > Let me know if it works.
> > >
> > >
> > > --
> > > Bruce Loehle-Conger
> > > MVP SQL Server Reporting Services
> > >
> > > "isaak" <isaak.peretsman at usa.dupont.com (no spam)> wrote in message
> > > news:4785EFE4-9436-4715-8AA4-A57CC8E9AC78@.microsoft.com...
> > > > How do I pass a multi-value parameter to a subreport?
> > > >
> > > > For example, if my main report has a multi-value parameter named @.p1 and
> > > > my
> > > > subreport's dataset is generated by SQL
> > > >
> > > > SELECT a,b FROM MyTable WHERE a IN (@.LongList)
> > > >
> > > > how do I then pass the user-selected @.p1 values from the main report to
> > > > the
> > > > @.LongList parameter in the subreport?
> > > >
> > > > I tried specifying JOIN(@.P1.Value,",") for a parameter value, but it did
> > > > not
> > > > work.
> > > >
> > > > Any help/suggestions will be appreciated. Thanks in advance
> > > >
> > >
> > >
> > >|||Sorry Isac,
I was trying to do the same thing but it did not work for me. Am I missing
something?
"Bruce L-C [MVP]" wrote:
> This is just a guess based on what I know is going on behind the covers but
> try the following. In your subreport make the Report Parameter @.LongList a
> multi-value parameter. Test the subreport stand alone and make sure it
> works. Then drop the subreport into your main report, right mouse click on
> it, parameters and map the report parameter from the subreport to the report
> parameter from the main report. You should not have to do anything fancy.
> Let me know if it works.
>
> --
> Bruce Loehle-Conger
> MVP SQL Server Reporting Services
> "isaak" <isaak.peretsman at usa.dupont.com (no spam)> wrote in message
> news:4785EFE4-9436-4715-8AA4-A57CC8E9AC78@.microsoft.com...
> > How do I pass a multi-value parameter to a subreport?
> >
> > For example, if my main report has a multi-value parameter named @.p1 and
> > my
> > subreport's dataset is generated by SQL
> >
> > SELECT a,b FROM MyTable WHERE a IN (@.LongList)
> >
> > how do I then pass the user-selected @.p1 values from the main report to
> > the
> > @.LongList parameter in the subreport?
> >
> > I tried specifying JOIN(@.P1.Value,",") for a parameter value, but it did
> > not
> > work.
> >
> > Any help/suggestions will be appreciated. Thanks in advance
> >
>
>|||Sorry I forgot to mention, did you manage to get working with multivalue
parameter?
"Henry Chen" wrote:
> Issak,
> I got it to work. Thanks!
> Henry
> "Henry Chen" wrote:
> > Isaak,
> > Since yours works, may I ask you a question?
> >
> > In my main report, the parameter that I want to pass to subreport is
> > "Fields!CallID.value", so I right-click the subreport in main report,
> > properties, parameter, parameter name is "CallID", parameter value is
> > "Fields!CallID.value". In my subreport, my sql query is (In subreport)
> >
> > select Tracker, EntryDate, EntryText from dbo.Journal
> > where CallID = @.CallID
> >
> > I go to paramters tab, I see the name is "@.CallID" and value => > "Parameters!CallID.value".
> >
> > when I run from main report, there is no error but subreport is not showing
> > in the main report. Do I miss something here? Thanks!
> > Henry
> >
> > "isaak" wrote:
> >
> > > Bruce,
> > >
> > > This works. Once again - thanks for your help.
> > >
> > > Isaak
> > >
> > > "Bruce L-C [MVP]" wrote:
> > >
> > > > This is just a guess based on what I know is going on behind the covers but
> > > > try the following. In your subreport make the Report Parameter @.LongList a
> > > > multi-value parameter. Test the subreport stand alone and make sure it
> > > > works. Then drop the subreport into your main report, right mouse click on
> > > > it, parameters and map the report parameter from the subreport to the report
> > > > parameter from the main report. You should not have to do anything fancy.
> > > >
> > > > Let me know if it works.
> > > >
> > > >
> > > > --
> > > > Bruce Loehle-Conger
> > > > MVP SQL Server Reporting Services
> > > >
> > > > "isaak" <isaak.peretsman at usa.dupont.com (no spam)> wrote in message
> > > > news:4785EFE4-9436-4715-8AA4-A57CC8E9AC78@.microsoft.com...
> > > > > How do I pass a multi-value parameter to a subreport?
> > > > >
> > > > > For example, if my main report has a multi-value parameter named @.p1 and
> > > > > my
> > > > > subreport's dataset is generated by SQL
> > > > >
> > > > > SELECT a,b FROM MyTable WHERE a IN (@.LongList)
> > > > >
> > > > > how do I then pass the user-selected @.p1 values from the main report to
> > > > > the
> > > > > @.LongList parameter in the subreport?
> > > > >
> > > > > I tried specifying JOIN(@.P1.Value,",") for a parameter value, but it did
> > > > > not
> > > > > work.
> > > > >
> > > > > Any help/suggestions will be appreciated. Thanks in advance
> > > > >
> > > >
> > > >
> > > >

Friday, March 9, 2012

Pass variable value to DataReader Source

Dear All,

I have created a DTS Package in Integration Services 2005.

Within the DTS Package declared a variable named xxx and passed a value 1234.

In the control flow i dropped a Data flow task and in the Property Expression Editor of DataFlow Task i defined

Property = [DataReader Source].[sqlCommand]

Expression = Variable name.

Now in the DataFlow Task Canvas dropped DataReaderSource.

How can i pass variable value to the SQLCommand ="Select * from table where name = Variable value.

regards

Sufian

This post explains how to do that...

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2009522&SiteID=1

|||

sorry , i have a diffrent problem.

I need to know how can i pass the variable value to the query supplied in the SQLCommand custom properties in datareader source on execution.

the variable datatype is Int32 and i am getting error when i set the expression property in the expression builder (Cannot convert System.Int32 to System.String).

Regards

Sufian

|||

mohd sufian wrote:

the variable datatype is Int32 and i am getting error when i set the expression property in the expression builder (Cannot convert System.Int32 to System.String).

You can't concatenate a string with an integer. You'll have to cast the integer as a string and THEN concatenate.

The cast operator is:

(DT_STR, <length>, <code_page>) variable_value

Code page will probably be 1252.

-Jamie