Data Loading from one table to another in the Same Database based on conditions .

Hi ALL ,
I have 2 tables Products and Product_info .
Product_info table Product_id is Primary key but not an identity column so auto increment of number needs to be performed from the Package only .
Requirement is :
IF the Product_ID is = 20 and Date lies in the previous month not the current month in the Products table then 
insert into the Product_info table based on below mentioned information .
1.If the Name  has tap then ignore it completely don't perform any insert for it.
2.If the Name has Zork in it then perform 2 inserts in the Product_info table having Product_info_id's 1 and 2 .
3.If the Name doesn't contains Zork or tap insert it in the Product_info table having Product_info_id 4.
Very new to SSIS package development it will be helpful if you can provide detailed information .
Source Table (Products table )
ID
NAME
Product_ID
Date 
Area_ID
1
P_tap_rus
20
13-01-2014
3
2
Enc_sap_top
10
15-01-2014
4
3
Yorl
20
05-02-2014
5
4
zork
20
20-01-2014
6
5
fadbt
10
22-01-2014
6
6
xyzzz_oprt
20
28-01-2014
5
7
def_type_ru
20
06-02-2014
2
8
acd_inc_tup
10
07-02-2014
3
9
bnf_dlk_fbg
20
03-02-2014
4
10
rtyui_vnmghj_sfdl
10
12-01-2014
5
11
wlwf_10103_123
10
04-02-2014
9
Destination table  (Product_info)
Porduct_ID
ID
Area_ID 
Product_info_ID
Column1
1
3
5
4
As NameString doesn’t contain Zork or Tap 
2
4
3
1
As Id is 4 so 2 inserts one for 1 and other for 2 in the Product_info_id column
3
4
3
2
4
6
5
4
5
10
5
4
6
11
9
4
Please let me know if any other information is required .
Thanks
Priya

Hi Priya,
You mentioned this was coming from two tables right? I believe I would try to perform the transformations with T-SQL in my source (If this is a possibility for you). Below is an example of something you could do.
WITH CTE
AS
SELECT ID, Product_ID, [Date], Area_ID,
CASE
WHEN Name like '%Zork%' THEN 1
ELSE 4
END AS Product_Info_ID
FROM [YourTable]
WHERE Product_ID = 20 and MONTH([DATE]) = MONTH(DATEADD(MM, -1, GETDATE())) AND NAME NOT LIKE '%tap%'
SELECT *
FROM CTE
UNION
SELECT ID, Product_ID, [Date], Area_ID, '2' AS Product_Info_ID
FROM CTE WHERE Product_Info_ID = 1
I hope this helps, Regards.

Similar Messages

  • Data loading from one table to another

    Hi,
    I want to load some data from a temp table to a master table. The master is having 40million records and the temp table is having 23 million records. Master table is having around 50 columns and we are adding 4new columns and the temp table is having 5columns. The data for these 4new columns are available in the temporary table also the employee column is there in common to these two table.
    I used a stored procedure to load the data, whcih uses a cursor. But its taking more that 6hours to load.
    Can any one suggest me a good technique to load data faster?
    Thanks,
    Santhosh.

    hi consider this case scenario which matches with yours.
    first of all you have to update not insert in master table.
    master table = emp with columns (emp_id, emp_name, emp_designation)
    to this original master table you added two more columns emp_salary, emp_department
    so now your master table looks like emp_id, emp_name, emp_designation, emp_salary, emp_department
    but when you do select * from master table, the last two columns salary & department are blank.
    Now you have another temp table with folllowing columns (emp_id, emp_salary, emp_department)
    now emp_id is common to master & temp tables & you want to put values from temp table into master tables? I think this is what ur trying to do..
    so for the above case the query i would write is
    update master_table m set m.emp_salary=(select t.emp_salary from temp_table t where
    t.emp_id=m.emp_id);
    commit;
    Regds.

  • Importing data from one table to another in the same schema

    I know this possibly very simple, but I can't seem to figure it out. I have
    two tables; one with live user data and another, identical except name, with
    archive data. I want to export data that has been flagged from table 1 and
    archive it by importing that data into table 2. I am able to modify the
    where clause of the export and get the proper data set, but cannot see a way
    (via OEM for Oracle 9.2.0.2) to change the name of the table to receive the
    import. I just end up shoving the same records back into table1. Is there
    an easy way to do this or am I just destined to polish up my script writing
    skills? Thanx!

    Yeah, you're right... however, I haven't had to write scripts since my old SQL/DS days on VM! I guess I've been lucky all these years.
    I guess the thing would go:
    1. Select from table1
    2. Insert into table2
    3. Delete from table1 after successful #2.
    I guess I'll get on it. Thanx!
    L

  • Is there a way of shifting purchases from one account to another with the same billing information, so that I don't lose purchases made by my iPhone when I sync?

    The AOL address I was using for my iTunes account has been deleted due to me not signing in for awhile and I'm afraid that I will lose all of my purchases made from my iphone when I sync it into iTunes for a much needed update and so that I can (hopefully) transfer its data to my new iPhone 4...
    The only time I have synced my current iPhone was when I activated it but since then I have not been able to sync with my computer and now have a new one.
    Sorry about the garbled way this is written but I desperately need help:
    1, Is there a way of shifting purchases from one account to another with the same billing information?
    Or
    2, is there a way of recovering my old account and changing the details?
    Any other help is greatly appreciated
    Thom

    You don't need to access your e-mail account, just get into your Apple account and change the e-mail address. If you can't access your Apple account, then you have a bigger issue to contend with.

  • Can I move applications from one user to another on the same computer?

    If I have two users on one mac, can I move applications from one user to another on the same computer?
    Thanks

    By default, apps are installed for all the users in /Applications

  • Moving Events and Projects from one location to another on the same hard drive.

    Hello.
    I've searched in the FCP X User Manual, on this forum and in Google, but have found no explanation of how to do this, so I'm posting this here in hopes that someone in our community will be able to help.
    I've previously stored my FCP X Events and Projects folders on an external 3TB hard drive, because there is more room on it than on the internal 1TB hard drive, but, since then, I've worked with other media apps, for video, photography and audio, the files for which are also stored on the external hard drive, and this has created a bit of clutter with no folder structure to keep it tidy.
    I like an organised file structure on my system, to keep it uncluttered, easy to navigate and efficient to use, so I put all the files for my photography, video and audio apps into their own folders, which are, in turn, stored in their appropriate folders for Audio, Photography and Video, and those three folders are stored in a folder called Media, and then I directed each app to its own files.
    The only app with which this has been a problem is FCP X. While there is a way of relocating projects and events from within FCP X, it allows the user to move them from one hard drive to another, and not, as I want, from one place to another on the same hard drive.
    I'm not sure if it matters, but perhaps it's relevant to mention before the next paragraph that the files that had previously been imported as events are, to save hard-drive space, stored in the events folder as shortcuts to the original files, which are stored elsewhere on the drive, rather than as duplicates of those files.
    In Finder, I copied the Events and Projects folders to their intended new locations and tried in the app to link the events and projects to their new Finder location. It seemed to have worked, until I moved the original folders to the Trash. On re-opening FCP X, it was clear that the linking hadn't worked. I returned the original folders from the Trash to their original location, but that didn't entirely reverse the problem. I noticed also that, in the original and duplicated Events folders, the shortcuts had lost their links to the original files stored elswehere on the drive.
    Fortunately I had run a backup before starting, so I restored the original folders and the app from the backup, and all was back to normal.
    I'd be grateful if anyone could advise me on whether or not it's possible to move FCP X events and projects from one place to another on the same hard drive with the app's compliance.
    Thank you.

    Ludio wrote:
    I'd be grateful if anyone could advise me on whether or not it's possible to move FCP X events and projects from one place to another on the same hard drive with the app's compliance.
    I
    Message was edited by: Russ H Apparently mis-read the questions.

  • How to move iTunes from one user to another on the same Windows 7  computer

    How to move iTunes from one user to another on the same Windows 7 computer? Thanks, Bob

    Move the iTunes library to a shared area and then into the desired location. If this isn’t the default one, launch iTunes with the Shift key held down and choose that library.
    (122379)

  • HT4878 How do i share my pictures, music and videos from one user to another on the same computer?

    How do i share my pictures, music and videos from one user to another on the same computer?

    lots of ways... you could use a thumb drive, you could drag files to the users public folder drop box, you could send it through email, you could use the internet servic called drop box (not to be confused with Apple's user public foldelr drop box).

  • How to transfer files from one partition to another on the same computer

    I had a crash could not boot back into my 8.1 upgrade. Went out bought standalone 8.1. I loaded it on HD free space now I want to transfer files from one partition to another.

    hi
    say there are two infoobjects X  and Y.
    X is existing infoobject and Y in new one.
    go to infosurce-search for X-create export datasource - map the rules and load the data.
    This is one way.
    Other way is u can use X as a reference object of Y so that both of them have same structure and both objects will share common database tables in BW which are exsting for X.
    Hope this helps.
    Kindly assign the points if it helps.

  • How can I migrate file shares & permissions from one volume to another on the same server?

    I am replacing a storage array and as part of that process, I need to move files/folders and Shares/permissions from one Volume to another volume within the same server.
    The server is Windows 2003 file server.  The file transfers are not a problem, moving all 40 shares with permissions etc. is my main concern because in order to maintain everything I need to change the drive letter of the new volume to match the old
    one so that links to various resources throughout the network do not break.

    Hi, 
    If you want to copy files/folders from one Volume to another volume within the same server, you could use the File Server Migration Tool (FSMT) or Robocopy to accomplish your goals. The tool can move all of the files from the shares on your original volume
    to the new volume.
    For more detailed information, you could refer to the articles below:
    File Server Migration Toolkit
    http://technet.microsoft.com/en-us/magazine/2006.10.utilityspotlight.aspx
    The File Server Migration Toolkit (FSMT) is a free download available at:
    http://www.microsoft.com/en-us/download/details.aspx?DisplayLang=en&id=10268
    Robocopy
    http://technet.microsoft.com/en-us/library/cc733145.aspx
    FSMT and Robocopy will not copy Share permissions but only NTFS permissions. So if the drive letter will not be changed, you can backup and restore the Share permission with steps here:
    Saving and restoring existing Windows shares
    http://support.microsoft.com/kb/125996
    Regards, 
    Mandy
    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.

  • How to transfer user settings from one account to another (on the same Mac)

    I'd like to create separate user accounts for "work" and "play" (so that I can do things like have separate address books, etc...). However, I already have LOTS of personalized settings (trackpad behavior, login items, etc) that I'd like to keep the same between the two accounts.
    Is there a way to transfer all of the user settings from one account to another?

    You'll need to copy your /Home/Library folder. Make sure you back up first before doing the following. Log out of both your Work and Play accounts. Log in to a third account with administrator privileges. Assuming you are copying from the account called "work" to the account called "play", enter the following in Terminal:
    sudo rm -rf ~play/Library (this deletes Play's Library folder.)
    sudo cp -R ~work/Library ~play/Library (this copies Work's Library folder to Play's folder.)
    sudo chown -R play ~play/Library (this fixes permissions of Play's new Library folder.)

  • How do I can link from one MXML to another in the same project?

    I planned to create a login page separated in my new Flex
    application. Maybe I am too attached to the WEB philosophy but I
    prefer to do it in that way. The login page will simply validate
    the login through a call to a CFC. While the CFC will also create
    the session variables I will need over the navigation of the user
    (once the login is validated), the variables (or more specifically
    the values of those variables) will serve as reference during the
    user's navigation. And those values are contains in the ColdFusion
    Session and can be accessed through CFCs.
    If the login is a success, I need to redirect the user to the
    appropriate page (in my case, the application is a help desk system
    so if the user is identified as a technician will go to the
    technician.mxml or if the user is identified as a sysadmin, will go
    to the sysadmin.mxml - simple as that). Now, I know it is possible
    to redirect using ExternalInterface.call function but is there
    anything more specific to Flex redirection from one MXML to
    another? Just like classes (where you can create dependency of a
    child classe to is parent)?
    Thank you

    I finally decided to use simply the method
    ExternalInterface.call to do this and it works fine! I passed
    parameters through the URL and I actually created CFM page that
    contains a copy of the HTML code generated by FlexBuilder (the CFM
    page give me the possibility to deal with the parameters).
    But I though that Flex can actually call another Flex and
    passing parameters directly without passing by the HTML page
    itself. A kind of memory scope but I guess I wish too much!!!
    ;-))

  • How can I migrate from one user to another within the same computer?

    My main user account in my desktop is becoming buggy after to many migrations from different computers and long time usage. I would like to migrate from one user to another user within the same computer to see if this improves my current problems.
    How can I do it in a reasonably safe and quick way?
    Thank you very much, cheers, Rui
    iMAC, OS 10.6.8... and yes, I love Snow Leopard light and handy... and all my programs work on it...

    Move small groups of files to the /Users/Shared/ folder or another location and see if the problems disappear. Moving everything to a new user account will in all probability transfer the problems.
    (119885)

  • How to load data from one Infobject into another in the same system??

    Hello All,
       i need to load hierarchy data (already existing in 1 Infobject) into another newly created Infobject in the same BW system.Is there a way to do it without involving flat files??
    Thanks soo much in advance
    Regards,
    Priya

    hi
    say there are two infoobjects X  and Y.
    X is existing infoobject and Y in new one.
    go to infosurce-search for X-create export datasource - map the rules and load the data.
    This is one way.
    Other way is u can use X as a reference object of Y so that both of them have same structure and both objects will share common database tables in BW which are exsting for X.
    Hope this helps.
    Kindly assign the points if it helps.

  • Error while data shifting from one table to another table

    i have two tables.
    in one table i dont have constraints.in anothe rtable i have constraints.
    my requiremnt is i have to shift data from unconstrained table to constrained table
    while shifting data any constaint violation is there system hasto raise error by specifying the error
    in below example it should be ename,esal values not null.
    i tried with save exception but it gives only error.i want error by mentiong that column names also ie ename,esal is not null
    if ename value only null then it should be give ename is null
    create table tablea (eno number(10), ename varchar2(20) not null, esal number(5) not null)
    create table tabl (eno number(10), ename varchar2(20) , esal number(5) )
    DECLARE
    TYPE tabl_tab IS TABLE OF tabl%rowTYPE;
    tab tabl_tab;
    -- create an exception handler for ORA-24381
    ERRORS NUMBER;
    dml_errors EXCEPTION;
    PRAGMA EXCEPTION_INIT (dml_errors, -24381);
    BEGIN
    SELECT *
    BULK COLLECT INTO tab
    FROM tabl
    WHERE rownum<=2;
    -- add '_SR' to the job_id of the most senior employees
    FORALL i IN tab.FIRST .. tab.LAST SAVE EXCEPTIONS
    insert into tablea values tab(i);
    EXCEPTION
    WHEN dml_errors
    THEN
    rollback ; --roll backs all the good records updation
    -- Now we figure out what failed and why.
    ERRORS := SQL%BULK_EXCEPTIONS.COUNT;
    DBMS_OUTPUT.put_line ('Number of statements that failed: ' || ERRORS);
    FOR i IN 1 .. ERRORS
    LOOP
    DBMS_OUTPUT.put_line ( 'Error #'
    || i
    || ' occurred during '
    || 'iteration #'
    || SQL%BULK_EXCEPTIONS (i).ERROR_INDEX
    DBMS_OUTPUT.put_line ( 'Error message is '
    || SQLERRM
    (-SQL%BULK_EXCEPTIONS (i).ERROR_CODE)
    END LOOP;
    END;
    how to implement that.

    it should give error as ename column is not null

Maybe you are looking for

  • How do I sync my new iphone without deleting everything in my library?!

    Last time I got a new iphone, all my music was deleted when I first synced it with my itunes library. How do I make sure that doesn't happen again?! What exactly do I have to click when the initial message pops up asking if I want to sync the new dev

  • Liquify filter crashes photoshop, everything is frozen.

    The liquify filter freezes my computer when i open it. Everything is runing perfectly on my computer until I click on the filter>liquify (cmd shift x), then no windows (the usual liquify window) pop up and everything is frozen. I won't even be able t

  • Do you use a screen protector? for powerbook.

    Do you use a screen protector for your powerbooks? if so, what do you use?

  • Steps to Enhance 0VENDOR_ATTR

    Hi SDN, Can someone please give me steps to enhancing 0VENDOR_ATTR matser data? I was able to get the data till the extractor and I can see that filed is populated in RSA3. I need to know the next steps in BW side icluding the dataloads. Thanks Priya

  • How to authorise users by Cost Ceter Groups for viewing KSB1

    We have created Cost Center Groups. We want only specific users to view the KSB1 report by Cost Center Group. Can anyone tell us what is the authorisation object for the same ? Or, is it possible to restrict KSB1 thru authorisation on CC groups ? - J