x
login about faq Site discussion (meta-askssc)

Sorting based on Parameter values

Hi, I am using SSRS 2008R2.i have a jobid param in my report which is a textbox and i am passing some values like 1,4,2,6. i want the report to be sorted in the way i passed the values to the parameter. For example if i passed the jobid's as 3,2,5 the report should be sorted in 3,2,5 order only. if i pass jobid's as 3,1,2 the report should come in 3,1,2 order. please help me in this. Thanks in advance...

more ▼

asked May 08 '12 at 12:38 PM in Default

sanjeev.matte gravatar image

sanjeev.matte
31 3 6 10

what are these numbers(1,4,2,6)? is that jobID or columns ordinals?

May 08 '12 at 02:03 PM Cyborg

Those are the values that i am passing to JobId param.

May 08 '12 at 02:35 PM sanjeev.matte
(comments are locked)
10|1200 characters needed characters left

1 answer: sort newest

I am not certain what you mean when you say you are passing the values to the parameter but if you are getting the values within TSQL then you could insert them into as temporary table and use the ID column in that table as the column to sort by ...

DECLARE @Sorting TABLE
    (
      ID INT IDENTITY ,
      MyVar INT
    )

INSERT INTO @Sorting
       ( [MyVar]
       )
       SELECT TOP 5 ABS(CHECKSUM(NEWID())) % 10 + 1
         FROM sys.COLUMNS

SELECT *
    FROM @Sorting AS s
    ORDER BY id

go

DECLARE @Sorting TABLE
    (
      ID INT IDENTITY ,
      MyVar INT
    )


INSERT INTO @Sorting
       ( [MyVar] )
    VALUES  ( 3 ),
         ( 6 ),
         ( 1 ),
         ( 2 ),
         ( 9 )


SELECT *
    FROM @Sorting AS s
    ORDER BY id
more ▼

answered May 08 '12 at 05:24 PM

Fatherjack gravatar image

Fatherjack ♦♦
38.8k 55 69 104

(comments are locked)
10|1200 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments



Facebook logo Follow Ask SSC on Facebook
Find Ask SSC on Google+
linkedin logo Find us on LinkedIn

Topics:

x9
x7

asked: May 08 '12 at 12:38 PM

Seen: 409 times

Last Updated: May 08 '12 at 05:24 PM

Copyright © 2002-2012 Simple Talk Publishing. All Rights Reserved. If you have any queries, please contact the site administrators.
Ask SQL Server Central is a community service provided by Red Gate.