Pass Parameter to Stored Procedure in Reporting Services

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jtrapat1
    New Member
    • Oct 2007
    • 3

    Pass Parameter to Stored Procedure in Reporting Services

    Im using sql server 2005 and visual studio 2005.
    I just want to create some reports and deploy them to the local reportserver for an intranet application by using reporting services.
    I'd like to use the report designer to create my reports but it seems kind of confusing with the many ways you can get into the report designer and be offered different options thru the wizards.
    Heres what I can do:
    I can create a generic report by using this route: (from inside the visual studio 2005 ide):
    File > New Project > Report Project Wizard and then I can set the datasource to my database table.
    Next, I get to the Query Builder and I dont know how to hook up my sp as the query:
    For my test query, I chose a table, selected all the fields in it and dragged them onto the report form.
    But, the designer seems very limited: most of the items in the toolbox are grayed out: labels, etc.
    Heres my sp:
    --------------------------
    Select ClientId, ContactName, ContactFirstNam e, ContactLastName ,CompanyName, Address1,Addres s2, City, State, Zip,
    EMail,phone,Fax , Status,Descript ion
    From Client
    Where ClientId = @ClientId
    ---------------------------------
    This stored procedure takes one parameter and I would like to browse for this sp so that I can set up and pass my parameter but Im lost.
    I went thru a bunch of tutorials all week and im at a dead end. It seems like it should be easier than Im making it.


    What is the best way to accomplish what I want for my situation?
    Thanks in Advance.
  • iburyak
    Recognized Expert Top Contributor
    • Nov 2006
    • 1016

    #2
    Try creating a view instead.

    Code:
    Create view Your_View
    AS
    Select ClientId, ContactName, ContactFirstName, ContactLastName,CompanyName, Address1,Address2, City, State, Zip,
    EMail,phone,Fax, Status,Description
    From Client
    Use your view with parameter

    Code:
    Select * from Your_View Where ClientId = @ClientId

    Comment

    • jtrapat1
      New Member
      • Oct 2007
      • 3

      #3
      Thanks for the response-
      Ive been working with this all day today.....

      I tried your suggestion and it worked.

      Thanks Again.

      Comment

      • gnorro
        New Member
        • Jun 2008
        • 1

        #4
        I have a similar situation.
        I have a web form in which I have different search fields. I wanti to do a search for some of these fields and then view a report with the search results. But I sould create the query dinamically because if I don't select a filter that field shouldn't be included in the query.

        for example:
        I search for field name and I don't insert anything inside surname field. the query is:
        select * from users where name = @name

        I search for field surname and I don't insert anything inside name field. the query is:
        select * from users where surname = @surname

        I search for field name and surname. the query is:
        select * from users where name = @name and surname = @surname

        how can i do that inside report? is it possible? If it's not possibile I need something that let me do that

        thanks

        Comment

        Working...