Ssrs 2008 r2 pass mutiple values to stored procedure that is being called

In an SSRS 2008 r2 report, I am currently calling a stored procedure called spRoom. I obtain the results of the stored procedure by creating a  temptable called #roomReults
The temp table that I am creating and using to obtain results looks like the following:
CREATE TABLE #roomResults(
                 studentID VARCHAR(15),
   endYear SMALLINT,
                 calendarID INT) 
INSERT  #roomResults
       EXEC [dbo].[spRoom] @endYear, @calendarID 
Currently I am only passing in one value for both paramters called: @endYear and @calendarID. However now I want to pass
in several values to each parameter.
I want to change the sql to look like the following:
 EXEC [dbo].[spRoom] IN (@endYear), In (@calendarID)
The above gives me syntax errors.
Thus I am wondering if you can show me how to change the sql listed above so that that I can pass in more than one value from the SSRS report parameters called @endYear and  @calendarID to the stored procedure called [spRoom]?

Wendy
What version  are you using? Since SQL Server 2008 we  can use table valued parameter
Create a user-defined data type with a single column.
Develop a procedure with a table variable as an input parameter.
Declare a table variable of the type of the user defined data type.
Loading 10 records into the table variable and pass the table 
variable to the stored procedure.
create type tt_example AS TABLE
 (spid int)
go
create procedure usp_example
 @spids tt_example READONLY
AS
 SELECT *
 FROM @spids
GO
declare @spids tt_example
insert into @spids
select top 10 spid
from sys.sysprocesses
exec usp_example @spids=@spids
Best Regards,Uri Dimant SQL Server MVP,
http://sqlblog.com/blogs/uri_dimant/
MS SQL optimization: MS SQL Development and Optimization
MS SQL Consulting:
Large scale of database and data cleansing
Remote DBA Services:
Improves MS SQL Database Performance
SQL Server Integration Services:
Business Intelligence

Similar Messages

  • Ssrs 2008 r2 pass paramter value to a sort

    In a new SSRS 2008 r2 report, I am going to be using sql within a dataset and not a stored
    procedure since will I need to pass multiple values to each parameter.
    One of the parameters that I will be working with is allowing the user to be able to pick what items
    they want to sort on. The sort will have 3 items that will be always be sorted on first which are:
    year, and school_number.  The users will be able to pick additional items to sort on like grade, and teacher.
    The following is the sql that I have so far:
    select year,  school_number, grade,teacher,room,course_number, course_name
    from dbo.school
    order by  year,  school_number, several parameter values.
    Thus I am wondering if you would modify the sql above so that I can allow the user to sort on the additional parameters in any order like grade,teacher,room,course_number, course_name?
    If any part of my request is not possible, I am wondering if you would show me what is possible in the sql?

    Hi jazz_dog,
    According to your description, you want to sort the report by grade,teacher,room,course_number or course_name based on a parameter selection. If in this case, we can add an expression in sorting to achieve your requirement:
    Add a parameter named Sort with the available values below to the report:
    Label: grade                                       Value: grade
    Label: teacher                                     Value: teacher
    Label: room                                        Value: room
    Label: course_number                         Value: course_number
    Label: course_name                            Value: course_name
    Add a the expression below to the tablix Sorting:
    =switch(Parameters!Sort.Value="grade",Fields!grade.Value,Parameters!Sort.Value="teacher",Fields!teacher.Value,Parameters!Sort.Value="room",Fields!room.Value,Parameters!Sort.Value=" course_number",Fields!course_number.Value,Parameters!Sort.Value="course_name",Fields!course_name.Value)
    If there are any other questions, please feel free to ask.
    Thanks,
    Katherine Xiong
    Katherine Xiong
    TechNet Community Support

  • SSRS 2008 not returning correct dataset from Stored Procedure

    Hi,
    I have a stored proc which returns different no. of columns as output based on the input parameter. The issue I am facing is that the SSRS 2008 is always populating the column list of the dataset with the first select list irrespective of the input
    parameter.
    How can I have the SSRS populate the column list based on the input parameter I am passing?
    eg.
    IF @type
    =
    'test'
    BEGIN
    SELECT 1 AS Col1,2 AS Col2
    END
    ELSE
    IF @type
    =
    'test1'
    BEGIN
    SELECT 1 AS Col1,2 AS Col2,3 AS Col3
    END
    SSRS always populates the dataset with two columns  viz col1 & col2 even when I pass
    'test1' as input parameter.
    Thanks for the help in advance.
    Sherin

    From my experiences, your dataset must return the same number of column and same name in both select statement.
     IF
    @type =
    'test'
    BEGIN
    SELECT 1 AS Col1,2 AS Col2,
    null AS Col3
    END
     ELSE
    IF @type
    =
    'test1' 
    BEGIN 
    SELECT 1 AS Col1,2 AS Col2,3 AS Col3
    END

  • Passing null value to stored procedure

    I am calling a stored procedure from ssis package. In my stored procedure I have parameters which is set to default value of null i.e if nothing is passed I need to assume the value of parameter to be null. 
    In ssis package I created a variable its a datetime variable but when I dont pass anything or blank 
    it automatically gets some date but instead I want it to pass NUll.
    Thank You for the help

    Hi Rama,
    SSIS evaluates null value in a date type variable as “12/30/1899 12:00:00 AM” by default. As long as the date type of the variable is date, it always gives “12/30/1899 12:00:00 AM” instead of null. This behavior still exists in SSIS 2012. So, I am afraid
    that you have to modify your stored procedure to yield to this by design behavior of SSIS.
    If you have concerns, I would suggest you submitting a wish at https://connect.microsoft.com/sql. 
    Connect site is a connection point between you and Microsoft, and ultimately the larger community. Your feedback enables Microsoft to make software and services the best that they can be, and you can learn about and contribute to exciting projects.
    Regards,
    Mike Yin
    TechNet Community Support

  • SSIS-How to pass multiple value to stored procedure from table row one by one using ssis package??

    I want to execute a stored procedure using ssis.But the problem  I am having is that there is a table with 200 rows with only
    single column.Now i want to execute stored procedure using value one by one from table .once the stored procedure is executed with top value from table i also want to delete that topmost column value and execute with next table value.and store the result in
    text file.
    please help me..or provide a package.

    If you want to do it in SSIS, a way to do this is by using For Each Loop as mentioned above.
    Create 1 OBJECT type variable (list of values) and one STRING type variable (one value at a time)
    Use EXE SQL Task with ResultSet = FULL RESULT SET and query = SELECT COL FROM TABLE ORDER BY COL ASC...output this to the OBJECT type variable 
    Next, a For Each loop container with Foreach ADO Enumerator, ADO object source variable = Object type variable and map that to String type variable with index = 0.
    Within your for each loop container, select another EXEC SQL Task and pass in an input parameter (the String type variable) and query = EXEC PROC ? -- WHERE ? = String type variable.
    This will execute your store procedure just for that one value out of the whole list.
    Now within the same For Each loop, select another EXEC SQL Task and again pass in an input parameter (the same String type variable) and query = DELETE FROM TABLE WHERE COL = ? -- WHERE ? = the current value 
    The above process should A) get the list of values from the table B) pick one value at a time and execute the proc and delete and right after delete that value from the table.
    Hope this helps.
    -- some further investigation/tweaking may require but it should help you get started.

  • How to pass FORM values to stored procedures !!!

    Hello guys,
    I developed a form, and when
    I click SAVE, i need to pass the form
    values(like deptno,dname) to a stored procedure !!!
    Please do let know, what should be the
    approach, I have done this is Dev2000,
    but how to do in Portal !!!
    Thanks for your time !!!
    A.Kishore
    null

    Hi,
    Take a look at this:
    http://technet.oracle.com:89/ubb/Forum81/HTML/000103.html
    Also, you can search through the archive for more topics.
    Thanks,
    Dmitry

  • Pass parameter values for stored procedure in URL, possible?

    Hi, everyone, Our system is Apex4.0.2 in Linux CentOS 5 on Oracle 11GR2, here is the procedure:
    create or replace  procedure  test_public(Cust_id integer)
    is
    begin
    owa_util.mime_header( 'text/xml', FALSE );
    owa_util.mime_header( 'application/octet', FALSE );
    -- Close the HTTP Header
    owa_util.http_header_close;
    htp.p(DBMS_XMLGEN.getXML('SELECT * FROM demo_orders where customer_id='|| cust_ID));
    end;
    +/+
    the call to the stored procedure is SUCCESSFUL when Test_public has no parameters, like:
    http://myserver/apex/myschema.test_public (OK)
    the question is : I want to pass 3 parameters into my stored procedure(on production procedure), just don't know How?
    Any suggestions are greatly appreciated

    Thanks, Vee, definitely working, I do appreciate your help.
    I have to use Stored Procedure in Apex: my goal is to setup RESTful web service for IOS and Andriod alike, but APEX RESTful only supports SQL Report ( the RESTFUL check Box goes away with PL/SQL returning Query report, much to my surprise), I need expose some data and the same time I need insert/update some data when the client consumes our data, a PL/SQL based Report will do, but as I found out only simple SQL report has RESTful service, a Before REGION Process will do too, but web service connection WON'T fire that process (normal page display will fire the process) so I'm out of option.... Man I wish APEX REST is not so so basic....

  • How to get all parameter names along with their values in stored procedure which is being executed

    Im using sql server 2012, is there any possible way to get all the parameters of a stored procedure along with the values passed to it.
    I need these things to build a xml. I mean this should happen in the procedure which being executed and it should be common for all the procedures.
    For example, let us suppose we have to procedures,
    uspSave, @name='test' @age=20
    uspDelete @id=2
    now in uspSave procedure, i need to get @name, @age and the values 'test', 20 and in uspDelete, i should get @id with value 2.
    For getting the column names, i tried this,
    select parameter_name from information_schema.PARAMETERS where specific_name=OBJECT_NAME(@@procid)
    now is it possible to loop through the result of above query and can we get the values.

    I think  you need running SQL Server Profiler to capture this info even in SQL Server 2012.
    Best Regards,Uri Dimant SQL Server MVP,http://sqlblog.com/blogs/uri_dimant/
    Blog : MS SQL Development and Optimization
    Blog : Large
    scale of database and cleansing

  • Pass values to stored procedure parameters

    I have a stored procedure in MS SQL 2005 that has a datetime parameter.  I want to be able to use the stored procedure but I only want to pass a date value and assume all times for this date. 
    When i add the stored procedure to the report it automatically creates the parameters and I don't know how to bypass them.
    Is it possible to create a date type parameter and then pass it to the stored procedure parameter?

    Hi Johua,
    Yes, you can create a date type parameter and pass it to a stored proc that accepts a datetime parameter.
    This will, however, need a container type of a report.
    1) Create a new report and also create a date parameter in this report
    2) Insert the original report as a subreport in, perhaps, the report header/footer section
    3) Create a formula with this piece of code:
         datetime({?Date},time(0,0,0));
    4) Link this formula with the subreport's stored proc parameter
    -Abhilash

  • Passing Values to Stored Procedure for "IN" Clause

    Hello All:
    I am trying to pass values to a stored procedure to use in an IN clause, and getting an "ORA-01722: invalid number".
    I believe this has something to do with how .Net handles strings and how I am trying to pass it to my stored procedure.
    The values I know need to be IN (2, 1) for the stored procedure to work, and I built a routine that creates a string value to pass in the format "2, 1", but I believe because this value is defined as a string in the .Net code, the leading and trailing apostrophe characters are causing the problem in the stored procedure.
    I have in my .Net code the following:
    oCommand.Parameters.Add("groupID_", OracleDbType.Varchar2).Value = GroupID;
    Where GroupID is defined as a string character, and has values of the following: 2, 1, but due to how .net handles it, it passes as "2, 1".
    So of course, inside my stored procedure,
    CREATE OR REPLACE PROCEDURE PAYSOL.sp_ProjectsManAppAndFundRpt(
    p_Cursor1 OUT SYS_REFCURSOR,
    p_Cursor2 OUT SYS_REFCURSOR,
    p_Cursor3 OUT SYS_REFCURSOR,
    p_Cursor4 OUT SYS_REFCURSOR,
    p_Cursor5 OUT SYS_REFCURSOR,
    groupID_ IN VARCHAR2)
    where I am defining the groupID_ parameter as a VARCHAR2, it is keeping the apostrophes, causing problems when I use it in my IN clause:
    AND S.GroupID IN (groupID_)
    What do I need to do to pass this value correctly? Is there something I can do inside the stored procedure to strip those characters, or do I need to pass it differently, or completely alter how I am handling this? I don't know the right path to head down, so wanted to seek some help.
    Thanks
    Andy

    IN Clauses and parameterized queries can be tricky beasts; so while logically it makes sense to do what you want (it does not do so in databases!)
    you can handle this problem in a few ways:
    1) anonymous sql (don't recommend)
    2) a user defined type and function as such
    --see  http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:210612357425
    --create a table of numbers ,create a function to split the "where" into a table
    --then return the data
    CREATE OR REPLACE type numberTableType as table      of number;
    create or replace function in_number(  p_string in varchar2 ) return numberTableType  AS
            l_string        long default p_string || ',';
            l_data          numberTableType := numberTableType();
            l_number        number ;
            N               NUMBER;
        BEGIN
          loop
              exit when l_string is null;
              n := instr( l_string, ',' );
             l_data.extend;
             begin --is user inputs a non-numeric value  skip the value
                l_number := cast(ltrim( rtrim( substr( l_string, 1, n-1 ) ) )  as number);
                l_data(l_data.count) := l_number ;
                EXCEPTION
                        WHEN VALUE_ERROR THEN
                            l_number := 0;
                        WHEN OTHERS THEN
                            raise ;
             end ;
             l_string := substr( l_string, n+1 );
        end loop;
        RETURN L_DATA;
      END in_number;
    --then your code
    AND S.GroupID IN (select column_value from table(in_number(groupID_))3) actually, just look at this blog posting! it does a better job at this than I am!
    http://tkyte.blogspot.com/2006/06/varying-in-lists.html

  • How to pass parameter from 1 stored procedure to another stored procedure inside crystal report

    Hi
    I have several stored procedure in my Crystal Report. I am wondering if it is possible for me to pass a parameter to one of the stored procedure and to use the result of that stored procedure E.g. CustomerCode. To another 2 stored procedure to generate the report dynamically?
    I have 3 stored procedure
    The 1st one is used to gather information and process the calculation
    another 2 stored procedure is used for generate the graph and both of them required to take 2 parameters. The 1st stored procedure will require 1 parameter (E.G. Reference Code) and will return a set of information including the data that could be use on the other 2 stored procedures.
    After I added these 2 stored procedure, it requires me to pass 3 parameters to the report. I would like to know if I could only pass the Reference Code for stored procedure 1 and use it to retrieve the information for the other 2 parameter?
    Thanks in advance
    Chi

    Hi Chi
    To pass parameter from 1 stored procedure to another stored procedure, you will have to create sub report. In your case you will have to create 2 sub reports for 2nd and 3rd stored procedure and link those sub reports with the main report using Reference Code field in order to pass the values.
    After creating the report when you will refresh the report, it will ask 4 parameters, one parameter for main report, one for the first subreport and two for second subreport to fetch the data correctly.
    Regards
    Poonam Thorat.

  • How pass progressive in a stored procedure

    Hi,
    I've 3 procedures:
    procedure EXEC_STOR_A;
    procedure EXEC_STOR_B (SERV_IN VARCHAR2, NAME_IN VARCHAR2);
    procedure EXEC_STOR_C (SERV_IN VARCHAR2, NAME_IN VARCHAR2);
    and I've created one stored procedure that run the 3 procedures simultaneously
    CREATE OR REPLACE PROCEDURE EXEC_MORE_PROC
    IS
    ERR_MSG VARCHAR2(300);
    ERR_NUM NUMBER;
    PROG NUMBER;
    BEGIN
    EXEC_STOR_A;
    EXEC_STOR_B ('OC', 'MY_STOR_B'));
    EXEC_STOR_C ('OC', 'MY_STOR_C'));
    EXCEPTION
    WHEN OTHERS THEN
         err_msg:= SUBSTR(SQLERRM, 1, 300);
         err_num:= SQLCODE;
         INSERT INTO REP_MESS (proc_name, err_code, err_msg, err_date)
    VALUES ('EXEC_MORE_PROC', err_num, err_msg, sysdate);
    COMMIT;
    END;
    EXEC_STOR_B and EXEC_STOR_C insert the value NAME_IN in the tables MY_TAB_B, MY_TAB_C and progressive starting from 0:
    CREATE TABLE MY_TAB_B (
    ID VARCHAR2 (12),
    NAME VARCHAR2 (32)
    PROGRESSIVE NUMBER);
    CREATE TABLE MY_TAB_B (
    ID VARCHAR2 (12),
    NAME VARCHAR2 (32)
    PROGRESSIVE NUMBER);
    for example when I execute the proc EXEC_MORE_PROC the first time I get (in MY_TAB_B):
    ID.........NAME........PROGRESSIVE
    1.........MY_STOR_B.........0
    10........MY_STOR_B.........0
    88........MY_STOR_B.........0
    99........MY_STOR_B.........0
    when I execute the proc EXEC_MORE_PROC the second time I get (in MY_TAB_B):
    ID.........NAME........PROGRESSIVE
    1.........MY_STOR_B.........1
    10........MY_STOR_B.........1
    88........MY_STOR_B.........1
    99........MY_STOR_B.........1
    Now I'd like to create my stored procedure, inserting into column NAME the value NAME_IN + progressive:
    for example when I execute the proc EXEC_MORE_PROC the first time I get (in MY_TAB_B):
    ID.........NAME..........PROGRESSIVE
    1.........MY_STOR_B_0.........0
    10........MY_STOR_B_0.........0
    88........MY_STOR_B_0.........0
    99........MY_STOR_B_0.........0
    when I execute the proc EXEC_MORE_PROC the second time I get (in MY_TAB_B):
    ID.........NAME..........PROGRESSIVE
    1.........MY_STOR_B_1.........1
    10........MY_STOR_B_1.........1
    88........MY_STOR_B_1.........1
    99........MY_STOR_B_1.........1
    How can I pass varchar2+number in my stored procedure??
    Thanks in advance!!

    and I've created one stored procedure that run the 3
    procedures simultaneouslyActually, you've create one procedure that runs the three procedures sequentially. If you want parallelism, you would have to do something like spawning three background jobs via DBMS_JOB.
    w I'd like to create my stored procedure, inserting
    into column NAME the value NAME_IN + progressive:
    How can I pass varchar2+number in my stored
    procedure??This looks to be the only question you're asking. The answer would seem to be to add a numeric parameter to the stored procedure(s). If the question is how to concatenate a number to a string, that's just
    <<string>> := <<string>> || to_char(<<number>>)Justin

  • SSRS Report in Visual Studio using a Stored Procedure as data source

    I have a stored procedure that creates a table used in an SSRS report that will be stored in AOT of Dynamics AX 2012 and be placed on a menu within Dynamics.  My concern is -- will  mutiple users be able to run the report at the same
    time for different filters without anything special being done in the stored procedure.
    The stored procedure deletes a table, then recreates each time the stored procedure is run.  The ssrs report executes the procedure.

    Hi,
    Thank you for posting in the MSDN forum.
    Since it is related to the SSRS, we will move this case to the
    SSRS forum, you will get dedicated support from the SSRS experts.
    Best Regards,
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

  • How to get return values from stored procedure to ssis packge?

    Hi,
    I need returnn values from my stored procedure to ssis package -
    My procedure look like  and ssis package .Kindly help me to oget returnn value to my ssis package
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    -- =============================================
    -- Author: <Author,,Name>
    -- Create date: <Create Date,,>
    -- Description: <Description,,>
    -- =============================================
    ALTER PROCEDURE [TSC]
    -- Add the parameters for the stored procedure here
    @P_STAGE VARCHAR(2000)
    AS
    BEGIN
    -- SET NOCOUNT ON added to prevent extra result sets from
    -- interfering with SELECT statements.
    SET NOCOUNT ON;
    -- Insert statements for procedure here
    --SELECT <@Param1, sysname, @p1>, <@Param2, sysname, @p2>
    truncate table [INPUTS];
    INSERT
    INTO
    [INPUTS_BASE]
    SELECT
    [COLUMN]
    FROM [INPUTS];
    RETURN
    END
    and i am trying to get the return value from execute sql task and shown below
    and i am taking my returnn value to result set variable

    You need to have either OUTPUT parameters or use RETURN statement to return a value in stored procedures. RETURN can only return integer values whereas OUTPUT parameters can be of any type
    First modify your procedure to define return value or OUTPUT parameter based on requirement
    for details see
    http://www.sqlteam.com/article/stored-procedures-returning-data
    Once that is done in SSIS call sp from Execute SQL Task and in parameter mapping tabe shown above add required parameters and map them to variables created in SSIS and select Direction as Output or Return Value based on what option you used in your
    procedure.
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • Passing data from Oracle stored procedures to Java

    We're going to write a new web interface for a big system based on Oracle database. All business rules are already coded in PL/SQL stored procedures and we'd like to reuse as much code as possible. We'll write some new stored procedures that will combine the existing business rules and return the final result dataset.
    We want to do this on the database level to avoid java-db round trips. The interface layer will be written in Java (we'd like to use GWT), so we need a way of passing data from Oracle stored procedures to Java service side. The data can be e.g. a set of properties of a specific item or a list of items fulfilling certain criteria. Would anyone recommend a preferable way of doing this?
    We're considering one of the 2 following scenarios:
    passing objects and lists of objects (DB object types defined on the schema level)
    passing a sys_refcursor
    We verified that both approaches are "doable", the question is more about design decision, best practice, possible maintenance problems, flexibility, etc.
    I'd appreciate any hints.

    user1754151 wrote:
    We're going to write a new web interface for a big system based on Oracle database. All business rules are already coded in PL/SQL stored procedures and we'd like to reuse as much code as possible. We'll write some new stored procedures that will combine the existing business rules and return the final result dataset.
    We want to do this on the database level to avoid java-db round trips. The interface layer will be written in Java (we'd like to use GWT), so we need a way of passing data from Oracle stored procedures to Java service side. The data can be e.g. a set of properties of a specific item or a list of items fulfilling certain criteria. Would anyone recommend a preferable way of doing this?
    We're considering one of the 2 following scenarios:
    passing objects and lists of objects (DB object types defined on the schema level)
    passing a sys_refcursor
    We verified that both approaches are "doable", the question is more about design decision, best practice, possible maintenance problems, flexibility, etc.
    I'd appreciate any hints.If logic is already written in DB, and the only concern is of passing the result to java service side, and also from point of maintenance problem and flexibility i would suggest to use the sys_refcursor.
    The reason if Down the line any thing changes then you only need to change the arguments of sys_refcursor in DB and as well as java side, and it is much easier and less efforts compare to using and changes required for Types and Objects on DB and java side.
    The design and best practise keeps changing based on our requirement and exisiting design. But by looking at your current senario and design, i personally suggest to go with sys_refcursor.

Maybe you are looking for

  • Cleared Document

    Hi, I have post the document thr. F-53 Dt 03.11.2007 ( vendor payment with clearing).But cheque cancelled in 03.12.2007. I have reverse the clearing document thr. FBRA and change the posting date (03.12.2007)and taken reversal reason 02 for cancellat

  • Thunderbolt device not showing up...

    I am having issues with my Thunderbolt device (Matrox MXO2 Mini) which allows me to monitor HD video on an external monitor when using Final Cut Pro on my iMac. When I opened my System Profiler, it says there is no devices connected to the thunderbol

  • Interactive Reports: Can values for 2nd filter be limited by first filter?

    Hi, I have a question for the inbuilt filter tool of interactive reports in apex 4.0.2.00.07. Let's assume my IR data looks like: Col1:*Col2* A:1 A:2 B:3 If I click on the header of Col1 I will be presented with filter possibilities "A" and "B" and c

  • Windows 2000 terminates LV app

    My LabVIEW5 or 6 application (exe or not) is closed by win2000pro because it creates several temp files in the temp directory. Windows suggests that these temp files are "NOT A VALID WINDOWS IMAGE". The temp files are created by CINS or dlls, ie. SQL

  • How do i run a class which has too many dependencies/class/jar file

    i am very new in java environment, i have developed a class which has to many jar file, it works fun when i run it from ide but problem arise which i wanna run it from command promt like java classname here is my code import java.sql.Connection; impo