Searching in Parameters

  • Hello,

    How do I search for a word that starts with a specific letter in a parameter within a matrix? My parameter works if I type out the full word.

    For example I have this as my data.

    B00055

    B00060

    B00065

    C00100

    C00200

    D00001

    D00002

    D00003

    If I type D00003 in my parameter I will get the record D00003 which is good but I want to be able to type out "D" and get all three records that start with "D".

    Any ideas? I figured it would be "D*" like in Access but it gives me a blank report.

    DP

  • WHERE ColumnName LIKE 'D%'


    Hugo Kornelis, SQL Server/Data Platform MVP (2006-2016)
    Visit my SQL Server blog: https://sqlserverfast.com/blog/
    SQL Server Execution Plan Reference: https://sqlserverfast.com/epr/

  • dpsql (4/14/2016)


    Hello,

    How do I search for a word that starts with a specific letter in a parameter within a matrix? My parameter works if I type out the full word.

    For example I have this as my data.

    B00055

    B00060

    B00065

    C00100

    C00200

    D00001

    D00002

    D00003

    If I type D00003 in my parameter I will get the record D00003 which is good but I want to be able to type out "D" and get all three records that start with "D".

    Any ideas? I figured it would be "D*" like in Access but it gives me a blank report.

    DP

    I just realized I posted in the wrong thread and meant to post in Reporting Services Forum. Since I apparently dont know how to delete my post I will just leave it up. lol

    Any assistance is still appreciated.

    DP

  • Hugo Kornelis (4/14/2016)


    WHERE ColumnName LIKE 'D%'

    Thank you for responding Hugo!

    That works on getting the report to show up with a specific letter.

    How can I get it where the reviewer can see the whole report and can type in "D%" in the parameter to get the data? Some reviewers will want C% and others will want B%.

    DP

  • dpsql (4/14/2016)


    Hugo Kornelis (4/14/2016)


    WHERE ColumnName LIKE 'D%'

    Thank you for responding Hugo!

    That works on getting the report to show up with a specific letter.

    How can I get it where the reviewer can see the whole report and can type in "D%" in the parameter to get the data? Some reviewers will want C% and others will want B%.

    DP

    I'm not very strong with SSRS, but in T-SQL you would pass in the letter in a variable (e.g. @Letter), and then use WHERE Column LIKE @Letter + '%'

    Do not bother the user of the report with having to type in %, that is a very unintuitive wildcard character. Just ask them to provide the letter.


    Hugo Kornelis, SQL Server/Data Platform MVP (2006-2016)
    Visit my SQL Server blog: https://sqlserverfast.com/blog/
    SQL Server Execution Plan Reference: https://sqlserverfast.com/epr/

  • Create a Parameter for your report. On the parameter setup Available Values tab, select 'Specify Values' and add your values in. This will populate the drop down for the user to select your letters. Then, set your query up to filter on LIKE @parmater + '%'.

    John Rowan

    ======================================================
    ======================================================
    Forum Etiquette: How to post data/code on a forum to get the best help[/url] - by Jeff Moden

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply