SQL Server Performance

dynamic sorting

Discussion in 'SQL Server Reporting Services' started by grinka, Aug 20, 2004.

  1. grinka New Member

    Hi,

    does anyone know if it is possible to pass the sorting order to a report thru parameters?
    I have a form where a user can specify how he would like the report to be sorted (company name asc, zip code desc, city desc, etc). The form's submit event generates the parameters that are passed to the report.
    I tried to set the sorting order of my table thru an expression (= Parameters!order_by.Value) but this does not work..

    thanks in advance for your help.

  2. derrickleggett New Member

    You need a CASE for each possible sort combination.

    ORDER BY
    CASE WHEN @sort = 'ASC' and @part = 'engine' THEN v.engine END ASC
    CASE WHEN @sort = 'DESC' and @part = 'engine' THEN v.engine END DESC


    MeanOldDBA
    derrickleggett@hotmail.com

    When life gives you a lemon, fire the DBA.

Share This Page