SSIS 2008 or 2012 Data Task: How to conditionally choose one of two flatfile columns on a per-row basis

I searched the textbooks and searchable forum posts for something related to my question, but could not find it. I'm hoping when after I describe my question that it might sound familiar to someone.
First, the context: another department using a black-box database product stopped use of one column and used a different column instead. However, the data in the flat-file export that I need to use for my own database must contain the entire
table. If it was a clean binary switch, that would be great: I could split the rows into two groups based on date and deal with it that way. Instead, there was a period of overlap while users slowly got the hang of the practice.  This means that I have
two columns where a row value is either in one column
or the other.
Now, the question: I currently use SSIS to import this flatfile into an SQL Server table and use a T-SQL script in an SQL Agent Job to handle the problem.
However, I was hoping I could do this on the SSIS side while importing the data so that it appears into the SQL Server destination table nice and clean.
This is a HIGHLY SIMPLIFIED view of my system, using dummy data and dummy names. The T-SQL script describes in essence my source and destination table and what I would like to do on the SSIS side. If a screenshot of my incomplete data tab will help, I can
do it, but at this point I'm providing what I hope presents the background without presenting distractions.  
Thank you for any hints or ideas.
use Learning_Curve;
go
if OBJECT_ID('dbo.Relation_A','U') is not null
drop table dbo.Relation_A;
create table dbo.Relation_A (
Rel_A_ID int primary key,
Rel_A_Value varchar(20) not null,
Rel_B_Value varchar(20) not null
insert into dbo.Relation_A values (1,'Unknown','Measured'),(2,'Measured','N/A'),(3,'Unknown','Measured'),
(4,'Measured','Unknown'),(5,'N/A','Measured'),(6,'Unknown','Measured');
if OBJECT_ID('dbo.Relation_D','U') is not null
drop table dbo.Relation_D;
create table dbo.Relation_D (
Rel_D_ID int primary key,
Rel_D_Value varchar(20) not null
insert into dbo.Relation_D
select
a.Rel_A_ID as Rel_D_ID,
case
when a.Rel_A_Value = 'N/A' or a.Rel_A_Value='Unknown'
then a.Rel_B_Value
else a.Rel_A_Value
end as Rel_D_Value
from dbo.Relation_A a;
go

You could have posted question in new thread.
Anyway, you can achieve it by using below tasks shown in attached picture.
- Merge Join will join by using first ID column
- Derived Column will have below expressions
[Column 1] == "" || ISNULL([Column 1]) ? [AnotherColumn 1] : [Column 1]
[Column 2] == "" || ISNULL([Column 2]) ? [AnotherColumn 1] : [Column 2]
Cheers,
Vaibhav Chaudhari
[MCTS],
[MCP]

Similar Messages

  • How to do choose one record in alv screen from dyn_table ?

    Experts:  How to do choose one record in alv screen from <dyn_table> ?
    FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
    RS_SELFIELD TYPE SLIS_SELFIELD.
    DATA: V_COUNT TYPE I.
    CLEAR: V_COUNT,<dyn_wa>.
    LOOP AT <dyn_table> INTO <dyn_wa>. "WHERE <?????> = 'X'.  I should how to do write ?
            V_COUNT = V_COUNT + 1.
    ENDLOOP.
      if not rs_selfield-tabindex eq 0 AND V_COUNT NE 0.
        IF R_UCOMM = '&CHANGE'.
          IF sy-subrc = 0.
            IF V_COUNT = 1.
              CALL SCREEN 100.
              perform dny_field_value_update.
              rs_selfield-refresh = 'X'.
            ENDIF.
          ENDIF.
        endif.
      endif.
    ENDFORM. "USER_COMMAND

    Anyways which version of SAP are you using ? As of SAPNW 7.0 Release 2 you can specify dynamic tokens with LOOP ... WHERE statement.
    My sap product is ecc5.0. Still thanks!
    Now I have solved it.
    FORM USER_COMMAND  USING R_UCOMM LIKE SY-UCOMM
                             RS_SELFIELD TYPE SLIS_SELFIELD.
      DATA: V_COUNT TYPE I.
      CLEAR:  V_COUNT,<dyn_wa>,IT_TOTAL.
      SY-INDEX = rs_selfield-tabindex.   
    READ TABLE <dyn_table> INTO <dyn_wa> INDEX SY-INDEX.
    ASSIGN COMPONENT 'KUNNR' OF STRUCTURE <DYN_WA> TO <dyn_field>.
      CONDENSE <DYN_FIELD> NO-GAPS.
      IT_TOTAL-KUNNR = <DYN_FIELD>.
      ASSIGN COMPONENT 'PLANTNO' OF STRUCTURE <DYN_WA> TO <dyn_field>.
      CONDENSE <DYN_FIELD> NO-GAPS.
      IT_TOTAL-MATNR = <DYN_FIELD>.
      ASSIGN COMPONENT 'CUSTOMERNO' OF STRUCTURE <DYN_WA> TO <dyn_field>.
       CONDENSE <DYN_FIELD> NO-GAPS.
      IT_TOTAL-CUSTOMERNO = <DYN_FIELD>.
      ASSIGN COMPONENT 'ZPERSON' OF STRUCTURE <DYN_WA> TO <dyn_field>.
      CONDENSE <DYN_FIELD> NO-GAPS.
      IT_TOTAL-ZPERSON = <DYN_FIELD>.
      IF SY-SUBRC = 0.
        "CHECK  <dyn_field> = 'X'.
        V_COUNT = V_COUNT + 1.
      ENDIF.
      if not rs_selfield-tabindex eq 0 AND V_COUNT NE 0.
        IF R_UCOMM = '&CHANGE'.
          IF sy-subrc = 0.
            IF V_COUNT = 1.
              CALL SCREEN 100.
              perform dny_field_value_update.
              rs_selfield-refresh = 'X'.
              "exit.
            ENDIF.
          ENDIF.
        endif.
      endif.
    Edited by: andy1982999 on Apr 2, 2010 8:42 AM

  • How do I eliminate one of two librarys in the itunes store

    How do I eliminate one of two librarys in the itunes store

    What do you mean by two libraries ? Do you mean two iTunes store accounts ? If so then any content that you've bought/downlaoded via each account will remain tied to that account and it can't be copied or transferred to a different account - if you haven't bought or downloaded anything with one of the accounts then don't use that account and just use the other one from now on. If you mean something else ... ?

  • How do I choose one of my favorite song or album from my iphone/iTunes while I connected to my car started directly from that chossen album.Thanks

    How do I choose one of my favorite song or album from my iPhone while I connected to my car start directly from that chosen album.Thanks

    When I connect my iPhone to my car start playing from one specific song every time and I need to change it to my one of favorite songs. How should I do that?
    thanks.....

  • I am having problems because two phone numbers are on the Apple ID, how do I choose one for imessage?

    I am having problems because two phone numbers are on the Apple ID, how do I choose one for imessage?

    Hello,
    In my opinion, this is the best procedure to use to update your BB OS:
    http://supportforums.blackberry.com/t5/BlackBerry-Device-Software/How-To-Reload-Your-Operating-Syste...
    However, the official download site:
    http://us.blackberry.com/support/downloads/download_sites.jsp
    shows your installed OS to be the current version from your carrier. Therefore, how your friends got a newer OS is a question to ask them and/or your carrier.
    You are, of course, free to use (via the above procedure) any carriers OS package...if another has the newer OS you want, you can use it. If you choose to do so, then simply insert, between steps 1 and 2 in the above procedure, the deletion, on your PC, of a file named VENDOR.XML
    Good luck.
    Occam's Razor nearly always applies when troubleshooting technology issues!
    If anyone has been helpful to you, please show your appreciation by clicking the button inside of their post. Please click here and read, along with the threads to which it links, for helpful information to guide you as you proceed. I always recommend that you treat your BlackBerry like any other computing device, including using a regular backup schedule...click here for an article with instructions.
    Join our BBM Channels
    BSCF General Channel
    PIN: C0001B7B4   Display/Scan Bar Code
    Knowledge Base Updates
    PIN: C0005A9AA   Display/Scan Bar Code

  • How to avoid the hard limit of 100 column and items per page?

    I have created a Form on a Table with Report. I need to create/edit approximately 175 items. The items on the Form have a limit of 100 column and items per page. What is the best way to carry the remaining items to another Form and doing an insert or update? or is the 100 column limit on the insert/update per table as well?
    Thank You.

    Hi Rick,
    The 100 item limit is on a page, not a table, so you shouldn't have any trouble with your insert or update processes.
    Here's a thought:
    Report currently has a column that links to the first page of items (page 14) with the retrieved row. Presumably you also have a Add New button on the report page that links to page 14 for a new row.
    Define a Next button on page 14 that branches to the second page of items (page 16). Also define a Previous button on page 16 to return to page 14. But page 16 would be the only page with a Save button.
    Now, if user clicks Add New, user will get a blank page 14. Once user enters the info and passes validation they click Next and will be sent to page 16 to enter the remaining info and Save.
    If user clicks one of the column links, they will be brought to page 14 with the clicked row - they can change whatever info there and click Next, or just click Next, to get to page 16. After any changes are made, they click Save.
    I'm assuming you've been thru the tutorials and realize that you'd really have two Save buttons defined for page 16 - one conditional on your primary key item having a value (existing record) and one conditional on it being null (new record) - check out the tutorials for more info, but this is how the application would know whether to run an insert process or an update process.
    Hope this all makes sense and can help,
    John

  • Exporting data on Excel recreating the sheet - SSIS 2008 R2-2012

    Hi,
    I need to read data from a SQL Server view to write the related rows on an Excel sheet, not with an append operation but with a delete operation against the sheet.
    Any suggests to me, please?
    Thanks

    Hi Pscorca,
    If the data volume is not large (for example less than a million), you can also use Lookup Transformation:
    http://www.rad.pasfu.com/index.php?/archives/46-SSIS-Upsert-With-Lookup-Transform.html 
    If the data volume is large, use Merge statement in a Execute SQL Task as Murali suggested.
    Regards,
    Mike Yin
    TechNet Community Support

  • SSIS 2008 R2 - Send email task with error in body message?

    Hi there, I'm newbie to SSIS.
    In Control Flow, I've Execute SQL task -> Data Flow Task (wirh some CSV export from SQL task)-> Send email on failure as shown in below screenshot. How can I get FOR ANY error message in
    Email Body inside "Send Mail Task- Failure" in case of failure?
    I found few articles on the internet but I'm newbie to SSIS and I need some step-by-setp guildeline to do this. Any idea? Many Thanks.

    Hi KM IT,
    You can enable logging for the package, and redirect the error message to a text file, and then display the content of the text file in the email message body.
    When configuring the logging, you can enable the logging for the entire package or each Control Flow Task. For the step-by-step guidance, please see:
    http://learnsqlwithbru.com/2009/11/26/configure-logging-in-ssis-packages/ 
    Then, in the Send Mail Task, you can configure the "MessageSourceType" property to “File Connection”, and select the log file. Of course, you can attach the log file as an attachment of the email.
    If you have any questions, please feel free to ask.
    Regards,
    Mike Yin
    If you have any feedback on our support, please click
    here
    Mike Yin
    TechNet Community Support

  • SSIS 2008 R2 - Export data to Flat File in another server

    Hello Everybody,
    I'm trying to export data from a table in database server to flat file in another server, however it is happening the error Access Denied. I'm using SQL Server Integration Service 2008 R2 to do this.
    I've checked all the ways that's happening could the level of security and could not resolve. 
    Please could someone tell me what I'm missing in this case? 
    Following error log:
    SSIS package "AtualizarDados.dtsx" starting.
    Information: 0x4004300A at Gerar arquivo, SSIS.Pipeline: Validation phase is beginning.
    Information: 0x40043006 at Gerar arquivo, SSIS.Pipeline: Prepare for Execute phase is beginning.
    Information: 0x40043007 at Gerar arquivo, SSIS.Pipeline: Pre-Execute phase is beginning.
    Information: 0x402090DC at Gerar arquivo, Geração de Arquivo [63]: The processing of file "\\targetserver\Export_File\Export_File.txt" has started.
    Warning: 0x80070005 at Gerar arquivo, Geração de Arquivo [63]: Access is denied.
    Error: 0xC020200E at Gerar arquivo, Geração de Arquivo [63]: Cannot open the datafile "\\targetserver\Export_File\Export_File.txt".
    Error: 0xC004701A at Gerar arquivo, SSIS.Pipeline: component "Geração de Arquivo" (63) failed the pre-execute phase and returned error code 0xC020200E.
    Information: 0x40043008 at Gerar arquivo, SSIS.Pipeline: Post Execute phase is beginning.
    Information: 0x402090DD at Gerar arquivo para DMZ, Geração de Arquivo [63]: The processing of file "\\targetserver\Export_File\Export_File.txt" has ended.
    Information: 0x4004300B at Gerar arquivo, SSIS.Pipeline: "component "Geração de Arquivo" (63)" wrote 0 rows.
    Information: 0x40043009 at Gerar arquivo, SSIS.Pipeline: Cleanup phase is beginning.
    Task failed: Gerar arquivo
    SSIS package "AtualizarDados.dtsx" finished: Success.
    Regards,
    Antonio Estima

    I got after using domain user. 
    Thanks to all

  • How do I delete one of two admin users in Mountain Lion?

    Hi,
    I have just migrated data from my iMac (Snow Leopard) to a new Macbook Pro (10.8). When setting up the computer at the Apple store, I chose my name and surname to set the computer (icon image is an eagle from the Apple library).
    When I then migrated the data (via external backup and using migration assistant) to the new Macbook, I was prompted to rename the user account ("the user account that you are transferring has the same name as an existing account on your computer. you can't have two user accounts with same name on your computer"). So I renamed the account differently.
    All my data has migrated correctly, including my emails. But I cannot see my personal icon in my mailboxes in Mail, I still see the image of the eagle. I went into system preferences and wanted to delete the original admin user account (the one with the eagle image) but it is greyed out and I cannot delete it.
    What is happening exactly? Why do I see the icon of the other admin user account in my mail and not the one I used on my old iMac. How can I delete this user account? Is there a particular reason why I couldn't delete this account?
    thanks for any guidance I can get on this

    Morning Gean40,
    Thanks for using Apple Support Communities.
    For more information on this, take a look at this article:
    You can't empty the Trash or move a file to the Trash
    http://support.apple.com/kb/ht1526
    Best of luck,
    Mario

  • How to find the difference between two timestamp column

    Dear All,
    please Solve my issue,
    I have Table name Record which has the following columns,
    Empid in number column, dat in timestamp
    which has the following values
    Expand|Select|Wrap|Line Numbers
    empid dat
    ====== ====
    101 4/9/2012 9:48:54 AM
    101 4/9/2012 9:36:28 AM
    101 4/9/2012 6:16:28 PM
    101 4/10/2012 9:33:48 AM
    101 4/10/2012 12:36:28 PM
    101 4/10/2012 8:36:12 PM
    101 4/11/2012 9:36:28 AM
    101 4/11/2012 4:36:22 PM
    Here I need to display the following columns,
    empid,min(dat) as start,max(dat) as end and difference(max(dat)-min(dat) for each day,
    for eg,
    Empid Strart end difference
    101 4/9/2012 9:48:54 AM 4/9/2012 6:16:28 PM 8.28
    like this.
    Here 3 different days are exists so It should return 3 records with the above mentioned columns,
    Please Help me to get this.
    Thank you,
    Regards,
    Gurujothi
    Edited by: Gurujothi on Apr 25, 2012 4:45 AM

    >
    101 4/9/2012 9:48:54 AM 4/9/2012 6:16:28 PM 8.28
    >
    why 4/9/2012 9:48:54?
    why not 4/9/2012 9:36:28 AM ?
    SQL>
    SQL> with t as
      2  (select  101 empid, to_timestamp('4/9/2012 9:48:54 AM', 'dd/mm/yyyy hh:mi:ss AM') dat from dual union all
      3  select 101, to_timestamp('4/9/2012 9:36:28 AM', 'dd/mm/yyyy hh:mi:ss AM') dat from dual union all
      4  select 101, to_timestamp('4/9/2012 6:16:28 PM', 'dd/mm/yyyy hh:mi:ss PM') dat from dual union all
      5  select 101, to_timestamp('4/10/2012 9:33:48 AM', 'dd/mm/yyyy hh:mi:ss AM') dat from dual union all
      6  select 101, to_timestamp('4/10/2012 12:36:28 PM', 'dd/mm/yyyy hh:mi:ss PM') dat from dual union all
      7  select 101, to_timestamp('4/10/2012 8:36:12 PM', 'dd/mm/yyyy hh:mi:ss PM') dat from dual union all
      8  select 101, to_timestamp('4/11/2012 9:36:28 AM', 'dd/mm/yyyy hh:mi:ss AM') dat from dual union all
      9  select 101, to_timestamp('4/11/2012 4:36:22 PM', 'dd/mm/yyyy hh:mi:ss PM') dat from dual
    10  )
    11  select empid, min(dat) as start_dat
    12  , max(dat) as end_dat
    13  , max(dat)-min(dat) diff
    14  from t
    15  group by empid, trunc(dat)
    16  /
         EMPID START_DAT                                         END_DAT                                           DIFF
           101 04.09.12 09:36:28,000000000                       04.09.12 18:16:28,000000000                       +000000000 08:40:00
           101 04.11.12 09:36:28,000000000                       04.11.12 16:36:22,000000000                       +000000000 06:59:54
           101 04.10.12 09:33:48,000000000                       04.10.12 20:36:12,000000000                       +000000000 11:02:24
    SQL>

  • How can I display one of two DataTables based on criteria

    I have two DataTables. One DataTable should be displayed or the other DataTable should be displayed in the same JSP based on some criteria. I wish I could put an if statement in the JSP page but how else can I do this? Is there a JSF tag that is like an if statement?

    Hi
    Try to use rendered attribute.
    Create boolean variable in your bean ie private boolean showTab1And in jsp type
    <h:dataTable id="tab1" value="..." var="..."  rendered="#{myBean.showTab1}">
    </h:dataTable>
    <h:dataTable id="tab2" value="..." var="..."  rendered="#{!myBean.showTab1}">
    </h:dataTable>if showTab1 is true, first dataTable shows, otherwise second dataTable is shown.
    Hope it helps
    Martin
    ps. You can combine value of rendered :
    rendered="#{myBean.boolVar1 && myBean.boolVar2 && !myBean.boolvar3}"

  • How to authorize just one of two devices with one account.

    My friends,
    I really don't know what forum to post this question: in iPhone, iPod Touch or iTunes.
    Well, the problem is simple. I have one Apple Apps account, one iPhone, mine, and an iPod Touch given away to my cousin. Both share the same iTunes library and I've synced in his iPod some of the apps I've bought. The problem is that I don't want my cousin to access less buy Apple apps by himself. I've made him clear that he shouldn't try to access, but he is a rebel boy and insists on accessing and therefore he blocks my account every time he tries guessing my password. How can I remove his iPod Touch authorization to access my account?????
    Desperado!!

    The iTunes account that is available on an iPhone and iPod Touch is transferred to the device via the iTunes sync process - with the iTunes account that iTunes is logged in to when syncing the device with iTunes.
    The only way to resolve this and remove your iTunes account from the Touch is restoring the Touch with iTunes as a new Touch followed by not syncing iTunes content with the same iTunes account. Let your rebel cousin fend for himself with his own iTunes account followed by purchasing and downloading his own iTunes content. That way when trying to be a rebel by purchasing iTunes content with someone else's account and not respecting your wishes - especially after giving him this Touch along with free iTunes account purchased with your iTunes account, he needs to learn what consequences can mean when not respecting you and your wishes. Or take the Touch away from him. I believe it sounds like it is time for some tough love.

  • How to randomly select one of two rows?

    I have a table from which I am selecting a husband and wife on separate rows. From each couple I want to select either the husband or the wife.
    I had faulty logic like the below:
    select * from
       (select row_number() OVER (partition by s.case_id order by n.date_created) rn,s.case_id scase_id,first_name,last_name
       from couples) x,
    (select abs(mod(dbms_random.random(),2))+1  randrow from dual) y
      WHERE y.randrow = x.rnwhich doesn't work because there is a separate random number for each row, so you could end up with (for example)
    RN randnum
    1 2
    2 1
    and get a NULL set.
    There must be a way to generate a single random number per case_id, but I'm having trouble thinking how to do it.
    Thanks,
    Jon

    with couples as (select 1         as case_id
                           ,'Sam'     as first_name
                           ,'Bachour' as last_name
                      from dual
                    union all
                     select 1          as case_id
                           ,'Jennifer' as first_name
                           ,'Hawkins'  as last_name
                       from dual
                    union all
                     select 2         as case_id
                           ,'John'     as first_name
                           ,'Smith' as last_name
                      from dual
                    union all
                     select 2          as case_id
                           ,'Nancy' as first_name
                           ,'Smith'  as last_name
                       from dual)
    select *
      from
        (select row_number() over (partition by case_id order by dbms_random.random) rn
               ,case_id
               ,first_name
               ,last_name
           from couples)
    where rn = 1

  • How do you sync one or two Audiobooks?

    I have about 180 books on my computer most downloaded from Audible.com. I only want the few on my IPHONE that I haven't yet listened to. I can't copy individual ones to IPHONE like I could on any of my IPODS, and I don't want to delete all the ones I have listened to from my computer. How can I sync "some" audiobooks with IPHONE. I cut and pasted a few to Party Shuffle play list, but I doubt that will work. Any suggestions?
    I-MAC G5 Flat Panel   Mac OS X (10.4)  

    I put a couple of my books on a playlist of their
    own. No problem then.
    I did that this morning - works fine. I created a Playlist called Audio and copied several books in there. Works great. WHEW! I think I'll check this question as answered.
    I-MAC G5 Flat Panel   Mac OS X (10.4)  

Maybe you are looking for

  • Cisco Jabber client to support Multiple e-mail domains

    Hi All, Per the following link, CUCM an IM&Presence starts supporting multiple domains at version 10: http://www.cisco.com/c/en/us/td/docs/voice_ip_comm/cucm/rel_notes/10_0_1/delta/CUCM_BK_C206A718_00_cucm-new-and-changed-1001/CUCM_BK_C206A718_00_cuc

  • OLE2 with MS Word -- Table Handling

    Dear All, Im using forms 6i. Im generating a word document from forms. That word document is a template. In that template im placing data at runtime.. My MS Word template has one table with 6 columns and 15 rows... But at runtime i may get data more

  • Problem mirroring on my apple tv

    Can play movies purchased through iTunes store from last year from MacBook pro through AirPlay. Can play YouTube videos play on AirPlay. Can'T watch movie I rented through iTunes on MacBook pro throu AirPlay to my TV. I get gray checkerboards. Can he

  • DIPSWITCH SETTINGS ON MAXPOWR G4/400 ZIF

    does anyone know the dipswitch settings for a maxpowr g4/400 zif processor to work in a g3 b&w thanks Larry B&W G3 400/ G3 DT WITH G4 UPGRADE/ 6400-180/ PB5300& 5300CS/ WALLSTREET/G3 AIO   Mac OS X (10.3.9)  

  • Report assignments in COPA report for several years

    Hello I have a COPA report, which contains of data for 2 or more years. I have setup a report assignment, so it is possible to step into a FI document from the 'Ref doc number' characteristic in the report. Unortunately it does not always finds the r