SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Splitting A Parameter From Report Services


Splitting A Parameter From Report Services

Author
Message
Stylez
Stylez
SSC Veteran
SSC Veteran (223 reputation)SSC Veteran (223 reputation)SSC Veteran (223 reputation)SSC Veteran (223 reputation)SSC Veteran (223 reputation)SSC Veteran (223 reputation)SSC Veteran (223 reputation)SSC Veteran (223 reputation)

Group: General Forum Members
Points: 223 Visits: 635
Hi To All

I have a Paramater From Reporting Services Named Classification in which it is a Multi Valued Paramater. i am trying to pass it to sql server to process and return a value but it doesnt seem to work

my parameter looks like this


declare @classification varchar(40)

after it is passed by the reporting services it will look something like this


set @classification = ('Active,Terminated')



i would like to use this in a Select statement named
select * from Table name where columnname in (@classification)

but everytime i pass that value(@classification) my query results return nothing. do you have a function to split the
@classification = ('Active,Terminated') variable

into

@classification = ('Active','Terminated')

i will now use this to create a select statement that would look like this


select * from table where columnname in ('Active','Terminated')

any form of assistance is very much appreciated

Best Regards,

N.O.E.L.
Adam Haines
Adam Haines
Hall of Fame
Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)

Group: General Forum Members
Points: 3888 Visits: 3135
Well your options are to parse the string directly to an inner join or to create a udf that returns a table, that you will inner join.


DECLARE @x XML
SET @x = '<i>' + REPLACE(@classification , ',', '</i><i>') + '</i>'

SELECT *
FROM MyTable a
INNER JOIN
(SELECT x.i.value('.', 'VARCHAR(7)') AS [Classification]
FROM @x.nodes('//i') x(i)) b
ON a.Classification = b.Classification



Like I said, your other option is to drop the xml into a function and inner join your table on the function.



My blog: http://jahaines.blogspot.com
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search