Multiple Column return in OLEDB Command SSIS 2008

Hi
Can someone help me on this please? I think in case we want to capture return value from a stored proc in SSIS OLEDB Command, we usually write something as
Exec ? = mystoredProc ?, ?, ?, ?
 [assuming 4 input parameter and a return value], but I want to capture all the column (5 in my case) of the output row of my stored procedure. So I tried something like, 
Exec ?,?,?,?,? = mystoredproc ?, ?, ?, ?
But looks like this is completely wrong. Any suggestion please?
Regards,
Rick
Regards, Avik M.

The syntax should be
EXEC mystoredproc ?, ?, ?, ?, ?, ?, ? OUTPUT, ? OUTPUT,...
Or you can use a table variable in the SP to return multiple valuesin one variable
in this notation
EXEC ? = mystoredproc ? ,? ... remains valid
Arthur
MyBlog
Twitter

Similar Messages

  • How to Call variable value in OLEDB Command SSIS

    Hi ,
    I am facing one issue in SSIS OLEDB Command.under OLEDB Command there is sql update query
        UPDATE dbo.ArchiveBBxFbapp
        SET LatestVersion = 0
        WHERE BBxKey = ?
    dbo.ArchiveBBxFbapp is the name of the table, which I want to change by dynamically on fly.
    table name I am getting from variable .
    I want to take same variable value instead of hard coded table name in update statement.
    suggest me the correct command
    thanks and regards,
    Vipin jha
    Thankx & regards, Vipin jha MCP

    For that you've to first store the query itself inside a variable after setting EvaluateAsExpression as true.
    Then use expression as below
    "UPDATE dbo." + @[User::TableName] +
    "SET LatestVersion = 0
    WHERE BBxKey = " + @[User::ColumnValue]
    Use option as SQL command from variable for data access mode property
    Then map the variable containing query above inside this OLEDB command.
    Please Mark This As Answer if it solved your issue
    Please Vote This As Helpful if it helps to solve your issue
    Visakh
    My Wiki User Page
    My MSDN Page
    My Personal Blog
    My Facebook Page

  • Excel source multiple column values to oledb destination single column in ssis 2012

    Excel sheet has 4 columns which is filled with data till 500 rows on each column. I want to insert those excel data into single column(PolicyIds) and am using oledb destination. In excel souce i dont hav any column header. Can anyone suggest me how can i do
    this effectively. (May be i can use script task to get range of data and use it as SQL variable). Is there any best approaches.
    Sample excel
    A          B             C             D
    1001     1005       1009        1013
    1002     1006       1010        1014
    1003     1007       1011        1015
    1004     1008       1012        1016

    Inside Excel Source, use Data Access Mode - SQL Command as below:
    select F1 from [Sheet1$] where F1 is not null
    union all
    select F2 from [Sheet1$] where F2 is not null
    union all
    select F3 from [Sheet1$] where F3 is not null
    union all
    select F4 from [Sheet1$] where F4 is not null
    -Vaibhav Chaudhari

  • How can I search multiple columns in a SQL command of Union tables

    Hi:
    We have a database with tables that are nearly identical that we use for production and production history.
    I have created an SQL command in Crystal 2008 to joins several of the tables and then added a "UNION" to connect the History and Prod tables.
    I need to search multiple (3 total) columns for 5 different data types, to return the records being investigated. I tried this using an "OR" statement in the where clause and have had inconsistant results.
    The first two or statement function perfectly the third works as long as the value being passed is numeric and the last two fail consistantly with invalid column name errors. It appears that crystal is getting confused and passing the wrong data type especially if I do a new search using a different option for the "?SearchParam"
    Can some one offer some insite on how I can search these fields to return the record data needed
    -- {?SearchParam} is the search parameter passed by Crystal that is a number 1 thru 5
    -- {?Search_Val} is a parameter that is passed by Crystal that is a string of what to search for 1 = Numeric CMP ord #("TBSLI21"."LI21_OR_NO"), 2 = Numeric CI ord # ( "TBSLI33"."LI33_CI_OR_NO"),
    --   3 =String  Ext Sys ord string ("TBSLI33"."LI33_EXT_SYS_SL_OR_NO"), 4 = String CMP Grp string ("TBSLI21"."LI21_OP_GRP_NO"), 5 = composit string PP ord string ("TBSOP13"."OP13_CLR_DAY" & "TBSOP13"."OP13_PP_GRP_SEQ_NO" & "TBSOP13"."OP13_CELL_ID")
    SELECT "TBSLI21"."LI21_OR_NO",
    "TBSLI21"."LI21_SH_DT_SCDL",
    "TBSLI21"."LI21_TS_EN_ORIG",
    "TBSLI21"."LI21_TS_SHIP",
    "TBSLI21"."LI21_SYS_ORD_CD",
    "TBSLI21"."LI21_SHIP_ID",
    "TBSLI21"."LI21_WRKST_ID",
    "TBSLI21"."LI21_LI_NO",
    "TBSLI33"."LI33_CI_OR_NO",
    "TBSLI33"."LI33_EXT_SYS_SL_OR_NO",
    "TBSLI21"."LI21_OP_GRP_NO",
    "TBSLI21"."LI21_LI_STAT",
    "TBSOP13"."OP13_OP_GRP_STAT",
    "TBSLI31"."LI31_LI_EV_DTL_TX",
    "TBSLI31"."LI31_DT_EN",
    "TBSLI31"."LI31_TM_EN",
    "TBSLI31"."LI31_LI_EV",
    "TBSLI21"."LI21_OP_WSH_FLNM",
    "TBSLI21"."LI21_PR_ITF_CD",
    "TBSLI21"."MFG_PLANT_CD",
    "MFG_PLANT_LI"."MFG_PLANT_CD" as PrefPlant,
    "TBSOP13"."OP13_OP_GRP_DSP_CD",
    "TBSLI21"."LI21_LI_DSP_CD",
    "TBSOP13"."OP13_CLR_DAY",
    "TBSOP13"."OP13_PP_GRP_SEQ_NO",
    "TBSOP13"."OP13_CELL_ID",
    "MFG_PLANT_LI"."PRFR_MFG_PLANT_FLG",
    "TBSLI21"."LI21_OP_GRP_PS_NO1",
    "TBSLI21"."LI21_POMS_MERGE_NO",
    "TBSLI31"."LI31_OP_ID",
    "TBSLI21"."LI21_LI_POR_FG",
    "TBSLI21"."LI21_BIN_ID",
    "TBSLI21"."LI21_TS_MRSHL",
    "TBSLI33"."LI33_CI_LI_NO",
    "TBSLI33"."LI33_SH_ADDR_1",
    "TBSLI33"."LI33_SH_ADDR_2",
    "TBSLI33"."LI33_SH_ADDR_3",
    "TBSLI33"."LI33_SH_ADDR_4",
    "TBSLI33"."LI33_SH_CITY_NM",
    "TBSLI33"."LI33_SH_ST_NM",
    "TBSLI33"."LI33_SH_ZIP_CD",
    "TBSLI33"."LI33_CU_NM",
    "TBSLI33"."LI33_CU_BUS_NM"
    FROM   ((("CMPREPORTING"."dbo"."TBSLI33" "TBSLI33" FULL OUTER JOIN "CMPREPORTING"."dbo"."TBSLI21" "TBSLI21" ON ("TBSLI33"."LI33_BS_OR_NO"="TBSLI21"."LI21_OR_NO") AND ("TBSLI33"."LI33_BS_LI_NO"="TBSLI21"."LI21_LI_NO")) LEFT OUTER JOIN "CMPREPORTING"."dbo"."TBSOP13" "TBSOP13" ON "TBSLI21"."LI21_OP_GRP_NO"="TBSOP13"."OP13_OP_GRP_NO") LEFT OUTER JOIN "CMPREPORTING"."dbo"."TBSLI31" "TBSLI31" ON ("TBSLI21"."LI21_OR_NO"="TBSLI31"."LI31_OR_NO") AND ("TBSLI21"."LI21_LI_NO"="TBSLI31"."LI31_LI_NO")) LEFT OUTER JOIN "CMPREPORTING"."dbo"."MFG_PLANT_LI" "MFG_PLANT_LI" ON ("TBSLI21"."LI21_OR_NO"="MFG_PLANT_LI"."OR_NO") AND ("TBSLI21"."LI21_LI_NO"="MFG_PLANT_LI"."LI_NO")
    WHERE   {?aSearchParam} = 1 and "MFG_PLANT_LI"."PRFR_MFG_PLANT_FLG"='Y' AND "TBSLI21"."LI21_OR_NO"=Cast( {?Search_Val} as Int)
    or {?aSearchParam} = 2 and "MFG_PLANT_LI"."PRFR_MFG_PLANT_FLG"='Y' AND "TBSLI33"."LI33_CI_OR_NO"=Cast( {?Search_Val} as numeric(12,0))
    or {?aSearchParam} = 3 and "MFG_PLANT_LI"."PRFR_MFG_PLANT_FLG"='Y' AND Convert( VarChar(20),"TBSLI33"."LI33_EXT_SYS_SL_OR_NO")= Convert( VarChar(20), {?Search_Val})
    or {?aSearchParam} = 4 and "MFG_PLANT_LI"."PRFR_MFG_PLANT_FLG"='Y' AND Convert( VarChar(8),"TBSLI21"."LI21_OP_GRP_NO") = Convert( VarChar(8), {?GroupNo})
    or {?aSearchParam} = 5 and "MFG_PLANT_LI"."PRFR_MFG_PLANT_FLG"='Y' AND Convert( VarChar(8), ("TBSOP13"."OP13_CLR_DAY" & "TBSOP13"."OP13_PP_GRP_SEQ_NO" & "TBSOP13"."OP13_CELL_ID")) = Convert( VarChar(8), {?GroupNo})
    Union
    SELECT "TBSLI21_HIST"."LI21_OR_NO",
    "TBSLI21_HIST"."LI21_SH_DT_SCDL",
    "TBSLI21_HIST"."LI21_TS_EN_ORIG",
    "TBSLI21_HIST"."LI21_TS_SHIP",
    "TBSLI21_HIST"."LI21_SYS_ORD_CD",
    "TBSLI21_HIST"."LI21_SHIP_ID",
    "TBSLI21_HIST"."LI21_WRKST_ID",
    "TBSLI21_HIST"."LI21_LI_NO",
    "TBSLI33_HIST"."LI33_CI_OR_NO",
    "TBSLI33_HIST"."LI33_EXT_SYS_SL_OR_NO",
    "TBSLI21_HIST"."LI21_OP_GRP_NO",
    "TBSLI21_HIST"."LI21_LI_STAT",
    "TBSOP13_HIST"."OP13_OP_GRP_STAT",
    "TBSLI31_HIST"."LI31_LI_EV_DTL_TX",
    "TBSLI31_HIST"."LI31_DT_EN",
    "TBSLI31_HIST"."LI31_TM_EN",
    "TBSLI31_HIST"."LI31_LI_EV",
    "TBSLI21_HIST"."LI21_OP_WSH_FLNM",
    "TBSLI21_HIST"."LI21_PR_ITF_CD",
    "TBSLI21_HIST"."MFG_PLANT_CD",
    "MFG_PLANT_LI_HIST"."MFG_PLANT_CD",
    "TBSOP13_HIST"."OP13_OP_GRP_DSP_CD",
    "TBSLI21_HIST"."LI21_LI_DSP_CD",
    "TBSOP13_HIST"."OP13_CLR_DAY",
    "TBSOP13_HIST"."OP13_PP_GRP_SEQ_NO",
    "TBSOP13_HIST"."OP13_CELL_ID",
    "MFG_PLANT_LI_HIST"."PRFR_MFG_PLANT_FLG",
    "TBSLI21_HIST"."LI21_OP_GRP_PS_NO1",
    "TBSLI21_HIST"."LI21_POMS_MERGE_NO",
    "TBSLI31_HIST"."LI31_OP_ID",
    "TBSLI21_HIST"."LI21_LI_POR_FG",
    "TBSLI21_HIST"."LI21_BIN_ID",
    "TBSLI21_HIST"."LI21_TS_MRSHL",
    "TBSLI33_HIST"."LI33_CI_LI_NO",
    "TBSLI33_HIST"."LI33_SH_ADDR_1",
    "TBSLI33_HIST"."LI33_SH_ADDR_2",
    "TBSLI33_HIST"."LI33_SH_ADDR_3",
    "TBSLI33_HIST"."LI33_SH_ADDR_4",
    "TBSLI33_HIST"."LI33_SH_CITY_NM",
    "TBSLI33_HIST"."LI33_SH_ST_NM",
    "TBSLI33_HIST"."LI33_SH_ZIP_CD",
    "TBSLI33_HIST"."LI33_CU_NM",
    "TBSLI33_HIST"."LI33_CU_BUS_NM"
    FROM   ((("CMPREPORTING"."dbo"."TBSLI33_HIST" "TBSLI33_HIST" FULL OUTER JOIN "CMPREPORTING"."dbo"."TBSLI21_HIST" "TBSLI21_HIST" ON ("TBSLI33_HIST"."LI33_BS_OR_NO"="TBSLI21_HIST"."LI21_OR_NO") AND ("TBSLI33_HIST"."LI33_BS_LI_NO"="TBSLI21_HIST"."LI21_LI_NO")) LEFT OUTER JOIN "CMPREPORTING"."dbo"."TBSOP13_HIST" "TBSOP13_HIST" ON "TBSLI21_HIST"."LI21_OP_GRP_NO"="TBSOP13_HIST"."OP13_OP_GRP_NO") LEFT OUTER JOIN "CMPREPORTING"."dbo"."TBSLI31_HIST" "TBSLI31_HIST" ON ("TBSLI21_HIST"."LI21_OR_NO"="TBSLI31_HIST"."LI31_OR_NO") AND ("TBSLI21_HIST"."LI21_LI_NO"="TBSLI31_HIST"."LI31_LI_NO")) LEFT OUTER JOIN "CMPREPORTING"."dbo"."MFG_PLANT_LI_HIST" "MFG_PLANT_LI_HIST" ON ("TBSLI21_HIST"."LI21_OR_NO"="MFG_PLANT_LI_HIST"."OR_NO") AND ("TBSLI21_HIST"."LI21_LI_NO"="MFG_PLANT_LI_HIST"."LI_NO")
    WHERE  {?aSearchParam} = 1 and "MFG_PLANT_LI_HIST"."PRFR_MFG_PLANT_FLG"='Y' AND "TBSLI21_HIST"."LI21_OR_NO"= Cast( {?Search_Val} as Int)
    or {?aSearchParam} = 2 and  "MFG_PLANT_LI_HIST"."PRFR_MFG_PLANT_FLG"='Y' AND "TBSLI33_HIST"."LI33_CI_OR_NO"= Cast( {?Search_Val} as numeric(12,0))
    or {?aSearchParam} = 3 and  "MFG_PLANT_LI_HIST"."PRFR_MFG_PLANT_FLG"='Y' AND Convert( VarChar(20), "TBSLI33_HIST"."LI33_EXT_SYS_SL_OR_NO")= Convert( VarChar(20),{?Search_Val})
    or  {?aSearchParam} = 4 and "MFG_PLANT_LI_HIST"."PRFR_MFG_PLANT_FLG"='Y' AND Convert( VarChar(8),"TBSLI21_HIST"."LI21_OP_GRP_NO")= Convert( VarChar(8), {?GroupNo} )
    or {?aSearchParam} = 5 and  "MFG_PLANT_LI_HIST"."PRFR_MFG_PLANT_FLG"='Y' AND Convert( VarChar(8), ("TBSOP13_HIST"."OP13_CLR_DAY" & "TBSOP13_HIST"."OP13_PP_GRP_SEQ_NO" & "TBSOP13_HIST"."OP13_CELL_ID")) = Convert( VarChar(8), {?GroupNo})

    This is actually a fairly easy fix - because of the way the "OR" works in SQL, you need to surround each "set" of statements in the or with parentheses.  So, it would look something like this:
    Where
    ({?aSearchParam} = 1 and "MFG_PLANT_LI"."PRFR_MFG_PLANT_FLG"='Y' AND "TBSLI21"."LI21_OR_NO"=Cast( {?Search_Val} as Int))
    or
    ({?aSearchParam} = 2 and "MFG_PLANT_LI"."PRFR_MFG_PLANT_FLG"='Y' AND "TBSLI33"."LI33_CI_OR_NO"=Cast( {?Search_Val} as numeric(12,0)))
    or
    ({?aSearchParam} = 3 and "MFG_PLANT_LI"."PRFR_MFG_PLANT_FLG"='Y' AND Convert( VarChar(20),"TBSLI33"."LI33_EXT_SYS_SL_OR_NO")= Convert( VarChar(20), {?Search_Val}))
    or
    ({?aSearchParam} = 4 and "MFG_PLANT_LI"."PRFR_MFG_PLANT_FLG"='Y' AND Convert( VarChar(8),"TBSLI21"."LI21_OP_GRP_NO") = Convert( VarChar(8), {?GroupNo}))
    or
    ({?aSearchParam} = 5 and "MFG_PLANT_LI"."PRFR_MFG_PLANT_FLG"='Y' AND Convert( VarChar(8), ("TBSOP13"."OP13_CLR_DAY" & "TBSOP13"."OP13_PP_GRP_SEQ_NO" & "TBSOP13"."OP13_CELL_ID")) = Convert( VarChar(8), {?GroupNo}))
    -Dell

  • How to retrieve multiple columns using "returning" in the Insert query.

    hi,
    wanted to know how to retrieve multiple columns using "returning" in the Insert Query.
    For retrieving one column we write the query as follows:
    Insert into TABLE values(1,2,3,4) returning COLUMN1 into PARAMETER
    But can we retrive multiple columns in the same query?
    am using oracle 10g and coding in .NET

    Hi,
    You can definetely get multiple values from a single query using the 'returning' clause.
    Eg : insert into emp (empno, ename, job, deptno) values (7324,'ADAM','MARKETING',30) returning ename, deptno into var1, var2; PN : var1 & var2 to be declared as varchar2 & number respectively.
    More insight into the 'RETURNING' clause in this link.
    http://www.samoratech.com/PLSQL/swArtPLSQLReturn.htm
    Regards,
    Bhanu.

  • Where condition on date column using OleDb Command?

    Hi,
    How to read date column from excel sheet usign OleDb command. Below code failing .
    OleDbCommand cmd = new OleDbCommand("SELECT Column1 FROM [sheet1$] WHERE createdDate < ="+Convert.ToDateTime("3/24/2015")+" ", connection);
    OleDbDataReader dr = cmd.ExecuteReader();
    Syntax error (missing operator) in query expression 'LastRun < =3/24/2015 12:00:00 AM'.
    How to write a where condition on date column excel sheet?
    Thanks
    PS.Shakeer Hussain

    Hi PS.Shakeer Hussain,
    In Excel, we store these data in excel is string type.  Based on your code, it is dataTime type. So if fails when compare with dataTime and string.
    Please try the following code, Useing DateTime.ToOADate Method to convert to the equivalent OLE Automation date. It works fine on my side.
    OleDbDataAdapter dbAdapter = new OleDbDataAdapter("select * from [Sheet1$] WHERE createdDate < "+DateTime.Parse("3/29/2015").ToOADate(), connExcel);
    Best regards,
    Kristin
    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.

  • Stored procedure in  package return multiple columns from multiple tables

    Hi ,
    Can a single stored procedure return multiple column values from different tables.
    example:
    tabA: col2, tabB:col3,tabC:col4 etc.
    one more question:
    if a stored procedure like to return 10 columns for a particular record from a single table do i need to define a TYPE statement for each colum like
    TYPE col1 is TABLE of varchar
    TYPE col2 is TABLE of varchar
    here i want to return only one row, not many rows.
    thanks

    You can try one procedure with OUT or IN/OUT parameters that collect the values from one or more sql statements.
    CREATE OR REPLACE PROCEDURE P1
    (P_COD IN TABLE.COD%TYPE,
    P_DESC1 OUT TABLE1.DESC1%TYPE,
    P_DESC2 OUT TABLE2.DESC2%TYPE)
    IS
    BEGIN
    SELECT table1.DESC1, table2.DESC2
    INTO P_DESC1, P_DESC2
    FROM TABLE1, table2 WHERE
    table1.COD = P_COD and
    table1.cod = table2.cod ;
    END P1;
    JP

  • Select function that returns multiple columns.

    Currently I have a function that will return 1 column and I can use that in a select statement. What I need is to return multiple columns from a table. In the function I have I return the street address from a table that holds information about dealers, I need to be able to also return the columns that contain the city, state, and zip code so it can be used in an sql select statement. How would I do this?
    My function:
    FUNCTION GET_ADDRESS(dealer_id IN number)
    RETURN tbl_dealer_info.c_street%TYPE AS
    v_rc tbl_dealer_info.c_street%TYPE;
    CURSOR get_dealer_cur IS
    SELECT c_street
    FROM tbl_dealer_info
    WHERE n_dealer_id = dealer_id;
    BEGIN
    v_rc := NULL;
    OPEN get_dealer_cur;
    FETCH get_dealer_cur INTO v_rc;
    IF get_dealer_cur%NOTFOUND THEN
    NULL;
    END IF;
    CLOSE get_dealer_cur;
    RETURN v_rc;
    EXCEPTION
    WHEN OTHERS THEN
    RETURN NULL;
    END GET_ADDRESS;
    My select statement:
    select GET_ADDRESS(1205) Street, DI.n_inactive_flag, DI.n_onhold_flag
    from tbl_dealer_info DI
    where DI.n_dealer_id = 1205;
    I would like to be able to select the street, city, state, and zip all in this select statement from the GET_ADDRESS function.
    Thanks,
    Lori Neirynck

    "The reality is you've probably already put your blinders on and you won't learn the best approach to solving your problem because you insist on asking a courtroom style question (just "yes" or "no" please)."
    Actually, I asked this question because I was looking for the best approach to my problem. I have an SQL statement that correctly selects everything it needs to from all 15 tables. The thing of it is it is very long and difficult to read. I wanted to try using functions so that I could change 12 AND/OR statements into 3 IF statements so everything is easier to read. I have received a couple of different ways to do this from other forums that assumed I knew what I was doing. I have gotten one to work, the other I'm still working on. I'll post the one that worked for others that want to know.
    SQL> insert into dealer_info values (1,'Me','13 success street', 'Wonder Town','Wonderland','1313');
    SQL> commit;
    SQL> create type t_address as object (
    2 street varchar2(100),
    3 city varchar2(30),
    4 state varchar2(30),
    5 zip varchar2(10));
    6 /
    Type created.
    SQL> create or replace function get_address (p_id number) return t_address
    2 is
    3 ret t_address := t_address(null,null,null,null);
    4 rec dealer_info%rowtype;
    5 begin
    6 select * into rec from dealer_info where id=p_id;
    7 ret.street := rec.street;
    8 ret.city := rec.city;
    9 ret.state := rec.state;
    10 ret.zip := rec.zip;
    11 return ret;
    12 end;
    13 /
    Function created.
    SQL> col name format a10
    SQL> col address format a70
    SQL> select name, get_address(id) address from dealer_info;
    NAME ADDRESS(STREET, CITY, STATE, ZIP)
    Me T_ADDRESS('13 success street', 'Wonder Town', 'Wonderland', '1313')
    1 row selected.
    -Lori

  • Split flat file column data into multiple columns using ssis

    Hi All, I need one help in SSIS.
    I have a source file with column1, I want to split the column1 data into
    multiple columns when there is a semicolon(';') and there is no specific
    length between each semicolon,let say..
    Column1:
    John;Sam;Greg;David
    And at destination we have 4 columns let say D1,D2,D3,D4
    I want to map
    John -> D1
    Sam->D2
    Greg->D3
    David->D4
    Please I need it ASAP
    Thanks in Advance,
    RH
    sql

    Imports System
    Imports System.Data
    Imports System.Math
    Imports Microsoft.SqlServer.Dts.Pipeline.Wrapper
    Imports Microsoft.SqlServer.Dts.Runtime.Wrapper
    Imports System.IO
    Public Class ScriptMain
    Inherits UserComponent
    Private textReader As StreamReader
    Private exportedAddressFile As String
    Public Overrides Sub AcquireConnections(ByVal Transaction As Object)
    Dim connMgr As IDTSConnectionManager90 = _
    Me.Connections.Connection
    exportedAddressFile = _
    CType(connMgr.AcquireConnection(Nothing), String)
    End Sub
    Public Overrides Sub PreExecute()
    MyBase.PreExecute()
    textReader = New StreamReader(exportedAddressFile)
    End Sub
    Public Overrides Sub CreateNewOutputRows()
    Dim nextLine As String
    Dim columns As String()
    Dim cols As String()
    Dim delimiters As Char()
    delimiters = ",".ToCharArray
    nextLine = textReader.ReadLine
    Do While nextLine IsNot Nothing
    columns = nextLine.Split(delimiters)
    With Output0Buffer
    cols = columns(1).Split(";".ToCharArray)
    .AddRow()
    .ID = Convert.ToInt32(columns(0))
    If cols.GetUpperBound(0) >= 0 Then
    .Col1 = cols(0)
    End If
    If cols.GetUpperBound(0) >= 1 Then
    .Col2 = cols(1)
    End If
    If cols.GetUpperBound(0) >= 2 Then
    .Col3 = cols(2)
    End If
    If cols.GetUpperBound(0) >= 3 Then
    .Col4 = cols(3)
    End If
    End With
    nextLine = textReader.ReadLine
    Loop
    End Sub
    Public Overrides Sub PostExecute()
    MyBase.PostExecute()
    textReader.Close()
    End Sub
    End Class
    Put this code in ur script component. Before that add 5 columns to the script component output and name them as ID, col1, co2..,col4. ID is of data type int. Create a flat file destination and name it as connection and point it to the flat file as the source.
    Im not sure whats the delimiter in ur flat file between the 2 columns. I have use a comma change it accordingly.
    This is the output I get:
    ID Col1
    Col2 Col3
    Col4
    1 john
    Greg David
    Sam
    2 tom
    tony NULL
    NULL
    3 harry
    NULL NULL
    NULL

  • SELECT in SELECT returning multiple columns ?

    10.2.0.3 version.
    I am trying to tune this query
    SELECT A.EMPLID, A.EFFDT, A.ACAD_PROG,
    (SELECT A1.DESCR FROM PS_ACAD_PROG_TBL A1
    WHERE A1.INSTITUTION = 'AUAO1' AND A1.ACAD_PROG = A.ACAD_PROG AND A1.EFFDT = (SELECT MAX (EFFDT) FROM PS_ACAD_PROG_TBL WHERE INSTITUTION = A1.INSTITUTION AND ACAD_PROG = A1.ACAD_PROG),
    (SELECT A2.DESCRSHORT FROM PS_ACAD_PROG_TBL A2
    WHERE A2.INSTITUTION = 'AUAO1' AND A2.ACAD_PROG = A.ACAD_PROG AND A2.EFFDT = (SELECT MAX (EFFDT) FROM PS_ACAD_PROG_TBL WHERE INSTITUTION = A2.INSTITUTION AND ACAD_PROG = A2.ACAD_PROG),
    as you can see it reading the table PS_ACAD_PROG_TBL two time to get two cloumns DESCR (alias A1) and DESCRSHORT (alias A2) exactly with the same where condition.
    I am trying to replace it with just one select returning multiple columns like this
    SELECT A.EMPLID, A.EFFDT, A.ACAD_PROG,
    (SELECT A1.DESCR, A1.DESCRSHORT FROM PS_ACAD_PROG_TBL A1
    WHERE A1.INSTITUTION = 'AUAO1' AND A1.ACAD_PROG = A.ACAD_PROG AND A1.EFFDT = (SELECT MAX (EFFDT) FROM PS_ACAD_PROG_TBL WHERE INSTITUTION = A1.INSTITUTION AND ACAD_PROG = A1.ACAD_PROG),
    but I am getting ORA-00913: too many values.
    Please help on how to get around this. Thanks in advance.

    William,
    On similar lines I am struggling with the below query based on your suggestions.
    SQL*Plus: Release 9.2.0.1.0 - Production on Wed Aug 5 14:17:21 2009
    Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.
    Connected to:
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    SQL> WITH arch_dup AS
      2       (SELECT   a.file_id,
      3                 a.sale_start,
      4                 a.activity_start,
      5                 a.activity_end,
      6                 a.item_code_cust,
      7                 a.division,
      8                 (SELECT MAX (DISTINCT (NVL (b.advertised, 'No')))
      9                    FROM ah_cust_gis_arch_stg b
    10                   WHERE b.file_id = a.file_id
    11                     AND NVL (b.sale_start, 'NULL') = NVL (a.sale_start, 'NULL')
    12                     AND NVL (b.activity_start, 'NULL') = NVL (a.activity_start, 'NULL')
    13                     AND NVL (b.activity_end, 'NULL') = NVL (a.activity_end, 'NULL')
    14                     AND b.item_code_cust = a.item_code_cust
    15                     AND b.division = a.division) advertised,
    16                 COUNT (*)
    17            FROM ah_cust_gis_arch_stg a
    18           WHERE a.file_id = 209
    19             AND a.status_id = 21
    20        GROUP BY a.file_id, a.sale_start, a.activity_start, a.activity_end, a.item_code_cust, a.d
    ivision
    21          HAVING COUNT (*) > 1)
    22  SELECT dup.*,
    23         (SELECT activity_id
    24            FROM (SELECT activity_id,
    25                         ROW_NUMBER () OVER (ORDER BY (activity_retail / activity_mult)) rnk
    26                    FROM ah_cust_gis_arch_stg
    27                   WHERE status_id = 21
    28                     AND NVL (sale_start, 'NULL') = NVL (dup.sale_start, 'NULL')
    29                     AND NVL (activity_start, 'NULL') = NVL (dup.activity_start, 'NULL')
    30                     AND NVL (activity_end, 'NULL') = NVL (dup.activity_end, 'NULL')
    31                     AND item_code_cust = dup.item_code_cust
    32                     AND division = dup.division
    33                     AND file_id = 209
    34                     AND UPPER (NVL (advertised, 'N')) = dup.advertised)
    35           WHERE rnk = 1) activity_id
    36    FROM arch_dup dup;
                       AND UPPER (NVL (advertised, 'N')) = dup.advertised)
    ERROR at line 34:
    ORA-00904: "DUP"."ADVERTISED": invalid identifierCan you throw some light on what to do to make the outer query columns available to inner query?
    Thanks,
    Raj.

  • Return multiple columns from an analytic function with a window

    Hello,
    Is it possible to obtain multiple columns from an analytic function with a window?
    I have a table with 4 columns, an id, a test id, a date, and the result of a test. I'm using an analytic function to obtain, for each row, the current test value, and the maximum test value in the next 2 days like so:
    select
    id,
    test_id,
    date,
    result,
    MAX ( result ) over ( partition BY id, test_id order by date RANGE BETWEEN CURRENT ROW AND INTERVAL '2' DAY FOLLOWING ) AS max_result_next_two_day
    from table
    This is working fine, but I would like to also obtain the date when the max result occurs. I can see that this would be possible using a self join, but I'd like to know if there is a better way? I cannot use the FIRST_VALUE aggregate function and order by result, because the window function needs to be ordered by the date.
    It would be a great help if you could provide any pointers/suggestions.
    Thanks,
    Dan
    http://danieljamesscott.org

    Assuming RESULT is a positive integer that has a maximum width of, say 10,
    and assuming date has no time-component:
    select
       id
      ,test_id
      ,date
      ,result
      ,to_number(substr(max_result_with_date,1,10)) as max_result_next_two_day
      ,to_date(substr(max_result_with_date,11),'YYYYMMDD') as date_where_max_result_occurs
    from (select
            id
           ,test_id
           ,date
           ,result
           ,MAX(lpad(to_char(result),10,'0')||to_char(date,'YYYYMMDD'))
               over (partition BY id, test_id
                     order by date
                     RANGE BETWEEN CURRENT ROW AND INTERVAL '2' DAY FOLLOWING )
            AS max_result_with_date
          from table)

  • [Forum FAQ] How do I send multiple rows returned by Execute SQL Task as Email content in SQL Server Integration Services?

    Question:
    There is a scenario that users want to send multiple rows returned by Execute SQL Task as Email content to send to someone. With Execute SQL Task, the Full result set is used when the query returns multiple rows, it must map to a variable of the Object data
    type, then the return result is a rowset object, so we cannot directly send the result variable as Email content. Is there a way that we can extract the table row values that are stored in the Object variable as Email content to send to someone?
    Answer:
    To achieve this requirement, we can use a Foreach Loop container to extract the table row values that are stored in the Object variable into package variables, then use a Script Task to write the data stored in packages variables to a variable, and then set
    the variable as MessageSource in the Send Mail Task. 
    Add four variables in the package as below:
    Double-click the Execute SQL Task to open the Execute SQL Task Editor, then change the ResultSet property to “Full result set”. Assuming that the SQL Statement like below:
    SELECT   Category, CntRecords
    FROM         [table_name]
    In the Result Set pane, add a result like below (please note that we must use 0 as the result set name when the result set type is Full result set):
    Drag a Foreach Loop Container connects to the Execute SQL Task. 
    Double-click the Foreach Loop Container to open the Foreach Loop Editor, in the Collection tab, change the Enumerator to Foreach ADO Enumerator, then select User:result as ADO object source variable.
    Click the Variable Mappings pane, add two Variables as below:
    Drag a Script Task within the Foreach Loop Container.
    The C# code that can be used only in SSIS 2008 and above in Script Task as below:
    public void Main()
       // TODO: Add your code here
                Variables varCollection = null;
                string message = string.Empty;
                Dts.VariableDispenser.LockForWrite("User::Message");
                Dts.VariableDispenser.LockForWrite("User::Category");
                Dts.VariableDispenser.LockForWrite("User::CntRecords");     
                Dts.VariableDispenser.GetVariables(ref varCollection);
                //Format the query result with tab delimiters
                message = string.Format("{0}\t{1}\n",
                                            varCollection["User::Category"].Value,
                                            varCollection["User::CntRecords"].Value
               varCollection["User::Message"].Value = varCollection["User::Message"].Value + message;   
               Dts.TaskResult = (int)ScriptResults.Success;
    The VB code that can be used only in SSIS 2005 and above in Script Task as below, please note that in SSIS 2005, we should
    change PrecompileScriptIntoBinaryCode property to False and Run64BitRuntime property to False
    Public Sub Main()
            ' Add your code here
            Dim varCollection As Variables = Nothing
            Dim message As String = String.Empty
            Dts.VariableDispenser.LockForWrite("User::Message")
            Dts.VariableDispenser.LockForWrite("User::Category")
            Dts.VariableDispenser.LockForWrite("User::CntRecords")
            Dts.VariableDispenser.GetVariables(varCollection)
            'Format the query result with tab delimiters
            message = String.Format("{0}" & vbTab & "{1}" & vbLf, varCollection("User::Category").Value, varCollection("User::CntRecords").Value)
            varCollection("User::Message").Value = DirectCast(varCollection("User::Message").Value,String) + message
            Dts.TaskResult = ScriptResults.Success
    End Sub
    Drag Send Mail Task to Control Flow pane and connect it to Foreach Loop Container.
    Double-click the Send Mail Task to specify the appropriate settings, then in the Expressions tab, use the Message variable as the MessageSource Property as below:
    The final design surface like below:
    References:
    Result Sets in the Execute SQL Task
    Applies to:
    Integration Services 2005
    Integration Services 2008
    Integration Services 2008 R2
    Integration Services 2012
    Integration Services 2014
    Please click to vote if the post helps you. This can be beneficial to other community members reading the thread.

    Thanks,
    Is this a supported scenario, or does it use unsupported features?
    For example, can we call exec [ReportServer].dbo.AddEvent @EventType='TimedSubscription', @EventData='b64ce7ec-d598-45cd-bbc2-ea202e0c129d'
    in a supported way?
    Thanks! Josh

  • SSIS 2008 – Read roughly 50 CSV files from a folder, create SQL table from them dynamically, and dump data.

    Hello everyone,
    I’ve been assigned one requirement wherein I would like to read around 50 CSV files from a specified folder.
    In step 1 I would like to create schema for this files, meaning take the CSV file one by one and create SQL table for it, if it does not exist at destination.
    In step 2 I would like to append the data of these 50 CSV files into respective table.
    In step 3 I would like to purge data older than a given date.
    Please note, the data in these CSV files would be very bulky, I would like to know the best way to insert bulky data into SQL table.
    Also, in some of the CSV files, there will be 4 rows at the top of the file which have the header details/header rows.
    According to my knowledge I would be asked to implement this on SSIS 2008 but I’m not 100% sure for it.
    So, please feel free to provide multiple approaches if we can achieve these requirements elegantly in newer versions like SSIS 2012.
    Any help would be much appreciated.
    Thanks,
    Ankit
    Thanks, <b>Ankit Shah</b> <hr> Inkey Solutions, India. <hr> Microsoft Certified Business Management Solutions Professionals <hr> http://ankit.inkeysolutions.com

    Hello Harry and Aamir,
    Thank you for the responses.
    @Aamir, thank you for sharing the link, yes I'm going to use Script task to read header columns of CSV files, preparing one SSIS variable which will be having SQL script to create the required table with if exists condition inside script task itself.
    I will be having "Execute SQL task" following the script task. And this will create the actual table for a CSV.
    Both these components will be inside a for each loop container and execute all 50 CSV files one by one.
    Some points to be clarified,
    1. In the bunch of these 50 CSV files there will be some exception for which we first need to purge the tables and then insert the data. Meaning for 2 files out of 50, we need to first clean the tables and then perform data insert, while for the rest 48
    files, they should be appended on daily basis.
    Can you please advise what is the best way to achieve this requirement? Where should we configure such exceptional cases for the package?
    2. For some of the CSV files we would be having more than one file with the same name. Like out of 50 the 2nd file is divided into 10 different CSV files. so in total we're having 60 files wherein the 10 out of 60 have repeated file names. How can we manage
    this criteria within the same loop, do we need to do one more for each looping inside the parent one, what is the best way to achieve this requirement?
    3. There will be another package, which will be used to purge data for the SQL tables. Meaning unlike the above package, this package will not run on daily basis. At some point we would like these 50 tables to be purged with older than criteria, say remove
    data older than 1st Jan 2015. what is the best way to achieve this requirement?
    Please know, I'm very new in SSIS world and would like to develop these packages for client using best package development practices.
    Any help would be greatly appreciated.
    Thanks, <b>Ankit Shah</b> <hr> Inkey Solutions, India. <hr> Microsoft Certified Business Management Solutions Professionals <hr> http://ankit.inkeysolutions.com
    1. In the bunch of these 50 CSV files there will be some exception for which we first need to purge the tables and then insert the data. Meaning for 2 files out of 50, we need to first clean the tables and then perform
    data insert, while for the rest 48 files, they should be appended on daily basis.
    Can you please advise what is the best way to achieve this requirement? Where should we configure such exceptional cases for the package?
    How can you identify these files? Is it based on file name or are there some info in the file which indicates
    that it required a purge? If yes you can pick this information during file name or file data parsing step and set a boolean variable. Then in control flow have a conditional precedence constraint which will check the boolean variable and if set it will execute
    a execte sql task to do the purge (you can use TRUNCATE TABLE or DELETE FROM TableName statements)
    2. For some of the CSV files we would be having more than one file with the same name. Like out of 50 the 2nd file is divided into 10 different CSV files. so in total we're having 60 files wherein the 10 out of 60 have
    repeated file names. How can we manage this criteria within the same loop, do we need to do one more for each looping inside the parent one, what is the best way to achieve this requirement?
    The best way to achieve this is to append a sequential value to filename (may be timestamp) and then process
    them in sequence. This can be done prior to main loop so that you can use same loop to process these duplicate filenames also. The best thing would be to use file creation date attribute value so that it gets processed in the right sequence. You can use a
    script task to get this for each file as below
    http://microsoft-ssis.blogspot.com/2011/03/get-file-properties-with-ssis.html
    3. There will be another package, which will be used to purge data for the SQL tables. Meaning unlike the above package, this package will not run on daily basis. At some point we would like these 50 tables to be purged
    with older than criteria, say remove data older than 1st Jan 2015. what is the best way to achieve this requirement?
    You can use a SQL script for this. Just call a sql procedure
    with a single parameter called @Date and then write logic like below
    CREATE PROC PurgeTableData
    @CutOffDate datetime
    AS
    DELETE FROM Table1 WHERE DateField < @CutOffDate;
    DELETE FROM Table2 WHERE DateField < @CutOffDate;
    DELETE FROM Table3 WHERE DateField < @CutOffDate;
    GO
    @CutOffDate which denote date from which older data have to be purged
    You can then schedule this SP in a sql agent job to get executed based on your required frequency
    Please Mark This As Answer if it solved your issue
    Please Vote This As Helpful if it helps to solve your issue
    Visakh
    My Wiki User Page
    My MSDN Page
    My Personal Blog
    My Facebook Page

  • Parameters in a OleDb Command Transformation

    Hi there,
    In order to prevent lookup errors in a lookup transformation, I've decided to go for an OleDb Command Transformation.
    This transformation should check the lookup and, if it turns out to be null, ir returns a dummy value. Otherwise, it would return the lookup value.
    This should be done by doing something like this:
    select coalesce( (select ID_Table2 from ID_Table2 where FK_Table1 = ?), 0)
    suposing Table2 has an atribute called "FK_Table1" that should match a column in the data flow.
    Now, such command result in this message:
    "An OLE DB record is available. Source "Microsoft SQL Native Client" Hresult: 0x80004005 Description: "Syntax eror, permission violation, or other nonspecific error".
    But, it I remove the coalesce and type the following command:
    select ID_Table2 from ID_Table2 where FK_Table1 = ?
    It presents me no errors and allows me to continue.
    Did i did anything wrong or is this something that is not possible to be done?
    I know i have the option to use a script task to do this operation, but that would turn the maintenance process a little more difficult.
    Otherwise, i know i could also re-direct the error from the lookup transformation and handle it. Though, my package has about 10 lookups and that would turn my package a lot more complex than
    Thanks in advance
    Best Regards
    André Santana

    Andre,
    You have more than one option to return a dummy value if the lookup fails. Here is one:
    1.       Configure the lookup component error output to 'ignore failure'; the place a derived column after the lookup to replace the nulls in the lookup column by the dummy value
    As Phil says, OLE DB command will perform the operation for every row then the performance is worse than using Lookup transform

  • OLEDB command - all parameter should be bound

    i am excuting my sp in OLEDB command 
    my proc has some required param and some null and 1 output param.
    i am executing like 
    exec p_sp param1=?,param2=? , paramn=? output
    i m just passing required filed and output, but when i go to comun mapping 
    its giving me error : all parameter should be bound and the one i am not passing here its showing up there in column mapping and i dont see output parameter.
    any help

    see
    http://www.rad.pasfu.com/index.php?/archives/24-Output-Parameter-of-Stored-Procedure-In-OLE-DB-Command-SSIS.html
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

Maybe you are looking for

  • MDM SP4 Web Services Not able to Connect

    Hello, I am trying to use standard MDM SP4 webservice. I deployed MDM_WEB_SERVICES_550.sca and also did required setting in visual composer as mentioned in the follwing blog. <a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.co

  • HTTP Error 403 - Customized Error Page Display Issue

    Hi, I have included 403 in <error-code> in my web.xml and defined proper security constraints. But when I try to access my JSPs directly on Mozilla I see my error page but I try in Internet, I can't see the same page. Can someone help me?

  • Network error IOException: network is unreachable

    Environment: SQL Developer 1.5.5 running on Windows XP Pro SP3 Connecting (or trying) to SQL Server 2000 at remote location. I can 'ping' the server and have downloaded and added the JTDS JDBC driver from Sourceforge.com to the Tools->Preferences->Da

  • How can I get what map versions are installed on m...

    Hi, How can I get the version of the currently installed maps on my phone please? I have a Garmin nuvi and this give me the proper version by going through Tools -> Setting -> Map -> Map Info. What is the equivalent for the symbian version 5.00. Than

  • Need Help Bad, Program Monitor Troubles

    Ive reinstalled windows 7 5 times in the last 3 days, my problem that im having is when i opening up premiere everything is find i think seems to be running fine. but when i try to color correct anything and i select any peramater in an effect im not