简体   繁体   中英

SSRS 2008 - How keep the SAME order enter in the parameter to be reflected in the report

I am working on a SSRS 2008 Report that when entering a list of ITEM numbers in a multiple data type parameter will return the Item Number, UPC, Description, and Item Status.

It works. But my problem is that it sorts my data in my report. Example. If I enter the following Item Numbers in the parameter: ZZZ DDD AAA HHH

My report shows the Data alphabetic as: AAA DDD HHH ZZZ

I want my data to be displayed in the order of the ITEM Number how I enter them.

I have One Data Set: SELECT ItemNo, UPC, Description, Status FROM Product WHERE ItemNo IN (@ITEM)

I have One Parameter: @ITEM Datatype: Text Allow multiple values

Please Help!

You need to parse the string into a table and then set an order to the table you've created. Then you have something to sort by.

First - create a function that you can call in your sp. (the answer to this question gives you exactly what you need)

then, in your query you can use the function just like a table.

DECLARE @x VARCHAR(100)
SELECT @x = 'ZZZ DDD AAA HHH'

SELECT * FROM f_split(@x,' ') param
WHERE param.seq > 1
ORDER BY param.val

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM