SCD issue

Hi,
I am implementing a Slow changing dimension with a parent-child hierarchy using OWB 10.2.0.2.
My data is like this:
Prod Parent_prod
P11 P1
P12 P1
P21 P2
P22 P2
P211 P21
P211 A21
A21 A2
I have to monitor changes tot he Parent say for example
A21 A2 can change to
A21 P2
Then I have to expire the row A21 A2 and make A21 P2 effective.
In OWB, I have implemented this as a Type dimension. With 'Prod' as the Business key and 'Parent_prod' to trigger changes.
This does not work properly. Here if I execute the mapping without any changes (A21 A2 still remains as A21 A2), I get an worning message "unable to fetch a stable set of rows from source" and in the table it has expired both
P211 P21
P211 A21
and created 2 separate rows with the same value. So basically it inserted 2 rows expiring two rows. This way whenever I load if there are no changes for these rows these rows will still be inserted and the tables keeps expanding.
How can I solve this issue? Any ideas please
Thanks a lot in adavnce!

You will still need something else as your business key in this instance, which is OWB's problem in determining a stable historical set.
A case in point:
e.g. First time you read the source table you have two rows:
Prod Parent
A1 A21
A1 A22
So you create the two rows.
Now, at your next refresh the source table contains:
Prod Parent
A1 A91
A1 A92
How is OWB to determine if A1/A21 changed to A1/A91 and A1/A22 changed to A1/A92? Or if A1/A21 changed to A1/A92 and A1/A22 changed to A1/A91?
You will need to find some other attribute or method to determine exactly how these relationships change over time in order to ensure that you are correctly creating your SCD.
Mike

Similar Messages

  • SCD issue when multiple records in the source dataset have same natural key

    When I load a dataset into a slowly changing dimension, sometimes the dataset contains multiple records for the same natural key. The rows are different by the column last_update_date (among other possible differences).
    The behavior I want is this: if during an ODI job run, the source dataset contains multiple records for one natural key, all records will load into the dimension, but only the record with the greatest last_update_date gets marked as the current record in the dimension. Right now, ODI is marking all of the incoming rows for the natural key as current. Any ideas? Thanks!

    Last_update_date is on the source but is not being sent to the target. Thus, it doesn't have an SCD behavior. I think my solution will be to pre-process the incoming records so I don't attempt to load multiple rows per natural key. I was just hoping someone here knew of an easier solution.
    If it helps, except for the SK, NK, Current Flag, and Effective Date fields, all SCD behaviors are "add row on change".

  • ETL patterns/strategies/templates/"best practices"

    The OWB Users Guide is good for defining the OWB operators, but I'm having some difficulty deciding how to best combine those operators to formulate a mapping. I'm hoping someone will be able to point me to documentation that will fill the gap. It wouldn't necessarily need to be OWB specific.
    Some example questions that I'm hoping an "ETL patterns" book or document would address:
    1. High level implementation decisions (Is the source data staged locally? How/when are the changed records identified?)
    2. Options for locally staging data.
    3. Options for implementing a Type I/II/III SCD.
    4. Options for implementing a cube.
    I was able to find "Slowly Changing Dimensions with Oracle9i Warehouse Builder" (http://otn.oracle.com/sample_code/products/warehouse/files/SCDWhitePaper.zip) that gave a lot of guidance on the SCD issues. The Type II SCD mapping presented in that document uses 10 operators. I never would have been able to formulate that on my own based on just reading the OWB documentation.
    Thanks,
    Brian

    Hi Torsten
    I assume you want to follow the framework described in the SCD Whitepaper.
    Where do I have to add the unbound table?You will need to insert data into a table, and not a dimension. More than this, since you have a need for using a sequence to feed the items with a surrogate key, there comes a matching problem (this is described in the whitepaper).
    The table must be added as the final destination of the data, after the last union (as shown in the Whitepaper).
    Is it an OWB table in the target module where the target dimension is located? Or do I have to create it in the database using sql*plus?It is neither, read the next question
    Why do you call it "unbound"? Because it is not a dimension or fact-table?The reason I call it unbound is that OWB does not have a "true" match between the object in the mapping and the object in the database. There is probable more to it than this, but let's just say, that it could be compared to some temporary table or something - usually it is not good to use unbound tables, but since we edit the "bound name" to an existing repository table, it's no problem - but be aware, that you will get a warning ever after...
    But is it true that I don't need the target dimension in this mapping now?No, you should use it as in the whitepaper, since you need to check if there is a trigger column that should instantiate a new record, or, if an insert or an update should be required.
    Or how do I connect the unbound table to the target mapping?You change the "bound name" (right-click the table, and choose "properties" and change the bound name to the name of the dimension).
    Torsten, generally you should follow the whitepaper, except for the last table/dimension :)
    Don't sweat if your stuck - I've clicked a gazillion times in OWB, in order to make this work - ask again, if I don't make sence :)
    Yours
    Kim

  • SCD Column Updation Issue

    Hi
    I have a query regarding updation of SCD columns.
    After executing the interface Actually I am able to get data in my target SCD columns
    Start_Date-:System Date
    End_Date-:2400-01-01 00:00:00.0
    End_Date-:1
    but if i make changes in my source data the End_Date and End_Date records are not reflecting with changes.
    I am using IKM "IKM Oracle Slowly Changing Dimension"
    In "Update existing rows" command code is :-
    update     <%=snpRef.getTable("L", "TARG_NAME", "A")%> T
    set     (
         <%=snpRef.getColList("", "T.[COL_NAME]", ",\n\t", "", "(((SCD_UPD) and !TRG) and REW)")%>
         <%=snpRef.getColList("", "T.[COL_NAME]", ",\n\t", "", "(((SCD_UPD) and TRG) and REW)")%>
         ) =      (
              select     <%=snpRef.getColList("", "X.[COL_NAME]",",\n\t\t\t","","(((SCD_UPD) and !TRG) and REW)")%>
                   <%=snpRef.getColList(",", "[EXPRESSION]",",\n\t\t\t","","(((SCD_UPD) and TRG) and REW)")%>
              from     <%=snpRef.getTable("L", "INT_NAME", "A")%> X
              where     <%=snpRef.getColList("", "X.[COL_NAME]\t= T.[COL_NAME]", "\n\t\tand\t", "", "SCD_NK")%>
              and     X.IND_UPDATE     = 'U'
    where     (<%=snpRef.getColList("", "T.[COL_NAME]", ", ", "", "SCD_NK")%>)
         in     (
              select     <%=snpRef.getColList("", "S.[COL_NAME]", ", ", "", "SCD_NK")%>
              from     <%=snpRef.getTable("L", "INT_NAME", "A")%> S
              where     S.IND_UPDATE     = 'U'
    <%=snpRef.getColList("and\t", "T.[COL_NAME]\t= 1", "\nand\t", "", "SCD_FLAG")%>
    <%=snpRef.getColList("and\t","[COL_NAME]\t= to_date ('01-01-2400', 'mm-dd-yyyy')","\nand\t","","SCD_END")%>
    Can anyone find where i am doing wrong??
    Thanks in advance
    Edited by: user10220907 on Dec 22, 2008 1:47 AM

    Hey rahulb216,
    Thanks for the question. If you are experiencing issues updating your iPhone, see this resource:
    If you can't update or restore your iOS device
    http://support.apple.com/kb/HT1808
    Thanks,
    Matt M.

  • Issue with OOTB Procurement and Spend report on top of W_AP_INV_DIST_F

    We are implementing OBIEE 11g on top of EBS R12. Observed today that AP_INVOICE_DISTRIBURIONS_ALL has a lot of records with PO_DISTRIBUTION_ID as NULL (This is expected as this table holds not only PO but also Expense tyoe invoices). The mapping used to populate W_AP_INV_DIST_F (SDE_ORA_APInvoiceDistributionFact) uses the PO_Distribution_ID to derive Product_ID. Thus, in W_AP_INV_DIST_F a lot of lines exist with PRODUCT_WID of NULL (which is also understable).
    My question is - In Procurement and Spend OOTB reports (for ex - Spend by Top Categories) , it is showing all records from W_AP_INV_DIST (and not filtering to Spend_Type of "PO Matched"). Thus, most of the records is going into the "Unspecified" bucket.
    Any thoughts on why the OOTB report would work like that (This is affecting any OOTB report that is built on top of W_AP_INV_DIST_F and involves products or product categories)?

    Out of curiosity, why do you only maintain 13 months of history in PeopleSoft? I have never heard of this. Dont the business users want to track PeopleSoft before 13 months? With regard to your question, given you are only able to load 13 months on a full load and this is impacting the links to the correct suppliers, you can consider keeping a refresh date on the tasks that load the W_SUPPLIER_D tables. This can prevent reload for the supplier dimension. However, I am not sure how you intend to handle the other dimensions as I assume you will have the same issue. If you only have 13 months of history, BI Apps will only load 13 months of history on a full load. Also for the SCD dimensions, there should be a CURRENT_FLAG that is set to Y only for the current record and there should still be a link to the previous records where CURRENT_FLG = N. As long as your SCD is working fine, and you can prevent the reload of supplier dimension via the refresh date changes, it may work. I would advise your PeopleSoft team to maintain history..esp if they want to take advantage of Analytics and trend analysis.

  • ODI - SCD Type 2 - Insert new row error

    Hi All,
    For Dimension I have a surrogate key, a natural key, and a column with "overwrite on change", start_date, end_date, current_record_ind. When I run the interface with the default SCD Type 2 for SQl server, this runs fine. But when I change that one column from "overwrite on change" to "insert new row", it fails on the update step. What should I be looking for anf fixing.
    Thanks for your time and help.

    DB: SQL Server 2008.
    IKM = IKM MSSQL Slowly Changing Dimension
    Error Message: ODI-1228 - Incorrect syntax near the keyword from.
    Code: update T
    set
    from database.dbo.Dim_type as T,
    database.dbo.I$_Dim_type as S
    where T.Cd = S.Cd
    and T.Current_rec_ind = 1
    and IND_UPDATE = 'U'
    To overcome the issue, I have commented the update code in the Knowledge module and the insert works, but for this one it is ok, but I have requirements where one column needs to be overwritten and other column changes will require to add a new record. How to handle both?
    Thanks for your time.

  • Follow-up to previous SCD thread

    I created the following thread for the issue I had with SCD.
    SCD question from ODIEXPERT.COM
    This is a flow-up thread to that.
    I am able to execute the mapping fine. But in the target table Surrogate_key is null. Also InitialTime stamp and End Time Stamp columns are also null.
    Please advice
    -app

    >
    Summary of few general repetitive issues with SCD Type 2 Make sure you have marked all the columns of SCD with required properties namely
    SURROGATE_KEY
    NATURAL_KEY
    ADD_ROW_ON_CHANGE
    UPDATE_ROW_ON_CHANGE
    CONTROL_FLAG
    STARTING_TIMESTAMP
    ENDING_TIMESTAMP
    SURROGATE_KEY - Needs to have a sequence ,Mapped to Target
    [ *SCHEMA.SEQUENCE_NAME.NEXTVAL* ]
    STARTING_TIMESTAMP AND ENDING_TIMESTAMP - Map with SYSDATE [ if datatype is  DATE , ] else SYSTIMESTAMP [ if datatype is  TIMESTAMP]
    CONTROL_FLAG -1
    NOTE :- ODI automatically populates ENDING TIMESTAMP AND CONTROL_FLAG , yet they need to be populated with a constant.
    ERRORS
    - If you are having invalid user.table.column, table.column, or column specification at Historize Old Rows
    SOLUTION
    - Enable the FLOW_CONTROL - YES and select the appropriate CKM ( CKM_ORACLE for Oracle ]
    Also make sure you have marked the required columns as ENDING_TIMESTAMP and CONTROL_FLAG
    ERROR
    - If you are getting invalid user.table.column, table.column, or column specification at Flag rows on Update or Update Existing Rows.
    SOLUTION
    - Mark the required columns with UPDATE_ROW_ON_CHANGE property.
    Generally all the errors occurs since the columns have not been marked with SCD properties correctly .

  • Transfer of Freight Conditions to Billing Document - exchange rate issue

    I am having an issue with my freight costs copy to customer billing document and the exchange
    rate causing the values to change. 
    Example - SCD freight = 400 USD, but vendor is being invoiced in BRL (807.44). 
    The freight is passed to customer billing document, which happens to have local document currency of
    EUR, but customer being invoiced in USD.  However the freight is going thru some kind of exchange rate conversion, causing my original 400 USD freight
    to show as 414.44 USD on the customer invoice.
    I am looking for way to keep the freight from changing between SCD + Customer Billing document.
    Regards
    Rita

    Can you share your screens from F-60 involving EUR to USD conversion?
    Also, try using transaction EWCT to test conversions between currencies,
    you can choose your two currencies that give you the issue, and test by
    entering the initial value, seeing the converted value.

  • Error in merge statement when trying to impliment SCD type 2 using merge...

    Hi ,
    I'm trying to impliment SCD type 2 using Merge using below blog as reference but sime how it is erroring out with error
    http://www.made2mentor.com/2013/08/how-to-load-slowly-changing-dimensions-using-t-sql-merge/
    Msg 207, Level 16, State 1, Line 40
    Invalid column name 'Current'.
    Msg 207, Level 16, State 1, Line 38
    Invalid column name 'Current'.
    Msg 207, Level 16, State 1, Line 47
    Invalid column name 'Current'.
    Here is the code below...
    --Create Temporaty table to hold dimension records
    IF OBJECT_ID('tempdb..#DimVirtualQueue') IS NOT NULL
    DROP TABLE #DimVirtualQueue;
    CREATE TABLE #DimVirtualQueue
    ( [VQ_name] [varchar](50) NULL,
    [contact_type] [varchar](50) NULL,
    [center_node_id] [int] NULL,
    [sed_id] [datetime] NULL,
    [eed_id] [datetime] NULL,
    [insert_date] [datetime] NULL,
    [Current] [char](1) NOT NULL
    INSERT INTO #DimVirtualQueue(VQ_name, contact_type, center_node_id, sed_id, eed_id, insert_date,[Current] )
    SELECT VQ_name, contact_type, center_node_id, sed_id , eed_id,GETDATE(),'Y'
    FROM
    ( --Declare Source and Target tables.
    MERGE dbo.tblSwDM_dim_VQ_test AS TARGET
    --Source
    USING (SELECT
    RTRIM(LTRIM(Stage.RESOURCE_NAME)) AS VQ_name,
    'Unknown' AS contact_type,
    0 AS center_node_id,
    CONVERT(INT,CONVERT(VARCHAR(8),GMT_START_TIME,112)) AS sed_id,
    CONVERT(INT,CONVERT(VARCHAR(8),ISNULL(GMT_END_TIME,'2070-01-01'),112)) AS eed_id,
    GETDATE() AS insert_date
    FROM dbo.tblGenesys_stg_RESOURCE_ Stage
    WHERE resource_type = 'queue'
    AND resource_subtype = 'VirtualQueue'
    AND NOT EXISTS (SELECT 1 FROM dbo.tblSwDM_dim_VQ AS dim
    WHERE RTRIM(LTRIM(stage.RESOURCE_NAME)) = RTRIM(LTRIM(dim.vq_name))) ) SOURCE
    ON TARGET.VQ_name = SOURCE.VQ_name
    WHEN NOT MATCHED BY TARGET
    THEN
    INSERT ( VQ_name, contact_type, center_node_id, sed_id, eed_id, insert_date,[Current] )
    VALUES (SOURCE.VQ_name,SOURCE.contact_type,SOURCE.center_node_id,SOURCE.sed_id,SOURCE.eed_id,SOURCE.insert_date,'Y')
    WHEN MATCHED AND TARGET.[Current] = 'Y'
    AND EXISTS (
    SELECT SOURCE.VQ_name
    EXCEPT
    SELECT TARGET.VQ_name
    --Expire the records in target if exist in source.
    THEN UPDATE SET TARGET.[Current] = 'N',
    TARGET.[eed_id] = SOURCE.eed_id
    OUTPUT $Action ActionOut, SOURCE.VQ_name,SOURCE.contact_type,SOURCE.center_node_id,SOURCE.sed_id,SOURCE.eed_id) AS MergeOut
    WHERE MergeOut.ActionOut = 'UPDATE';
    --Insert data into dimension
    INSERT tblSwDM_dim_VQ_test
    SELECT VQ_name,contact_type,center_node_id,sed_id,eed_id,insert_date,[Current] FROM #DimVirtualQueue
    Any help to resolve issue is appreciated...
    Thanks,
    Vishal..

    You need to show the DDL of your target table: dbo.tblSwDM_dim_VQ_test.
    Do you have a column named [Current] in this table?

  • Setting END_DATE in OWB 11g R1/R2 SCD type 2

    Hi
    I have this issue which needs an immediate solution. The SCD2 design in OWB 11g R1/R2 works well except that it does not allow a programmer to populate the value of END_DATE with a field from source.
    I observed that one can set the value of end_date in the dimension properties (via inspector) for initial records/open records.
    a. default effective time of initial record and
    b. default effective time of open record
    My question is for the above two properties being set on the SCD History logging properties on target level in mappings, can we set them to a particular date field coming in from the source?
    The only work around I found was to have a function which returns me a particular value from the source which can be called within the properties of these two fields, but other than that, we cannot directly populate the END_DATE field as it is a derived field within the SCD2 logic generated in the background.
    Please if you could answer this it would be great
    Birdy

    Hi Oleg
    I want the STA_FROM to drive my DIM_TO as well
    So I may have sets of records say
    Business/Natural key : Account number
    Triggering column: Name
    Suppose I load all of this today
    Account_number STA_FROM Name
    1001 01-aug-2010 Dummy1
    1001 03-aug-2010 Dummy2
    1001 05-aug-2010 Dummy3
    1001 07-aug-2010 Dummy4
    1002 01-sept-2010 Dummy_1
    Hence Dimension data will be
    Account_key Account_number EFFECTIVE_DATE END_DATE Name
    1 1001 01-aug-2010 03-aug-2010 Dummy1
    2 1001 03-aug-2010 05-aug-2010 Dummy2
    3 1001 05-aug-2010 07-aug-2010 Dummy3
    4 1001 07-aug-2010 31-dec-9999 Dummy4
    5 1002 01-aug-2010 31-dec-9999 Dummy_1
    If you notice, I am driving both Effective and end date by the STA_FROM
    I have already achieved this in the hard coded SCD logic by using Lead function to derive my end dates for "force-closing" records.
    But the SCD wizard does not allow us to drive the value of end date based on a field coming from the source. Now in my case, the STA_FROM can also be value of an input load date parameter in some cases.
    It would have been nice to allow population of END_DATE on target dimension operator instead of giving only the option of setting it in the operator properties.
    Hope its much clearer now
    Birdy

  • Currency on SCD line item

    Dear SAP Experts,
    We have a vendor that is defined in 2 different company codes (United States and Canada).   Currency for United States is 'USD'.  Currency for Canada is 'CAD'.  As you can see from the Vendor Display transaction (VK03), the purchasing data tab which contains the currency for this vendor is not by company code.  It is just by purchasing organization.   We use the same purchasing organization for this vendor regardless if this vendor is defined in company code for the United States or Canada.
    When I create a SCD (Shipment Cost Document) for this vendor and the Transportation Planning Point on the shipment is defined for the Canada company code, I always get the United States currency in the SCD line item because the XK03 (Purchasing Data) tab has 'USD' as the currency.
    How can I create a SCD using a vendor with a Transportation Planning Point defined for Canada and get the correct currency of 'CAD'?   
    In other words, I would like to have the currency of the company code based on the Transportation Planning Point placed in the SCD and not the currency on the Purchasing Data tab from the vendor.
    Thank you.
    Sunil.

    Dear
    1.While costing on a line item system message shows " Material has no BoM" whereas BoM for the "Fert" has already been loaded.
    Please check the following :
    1.Goto CS02-BOM -Status header long text -BOM status should be 1
    2.Check the Validity of the BOM which should inline with your currect date when you are doing costing
    3.Check whether you have make Costing Relevency Indicator as -X-Rlevent for costing 100%
    4.Check whether you have not set the Deletion Flag for BOM  at header level .
    2. Will be there any issue if any "Fert" is under line "Fert" i.e., header item is a "Fert" and one "Fert" is under that and "Halb" is under this Fert ?
    I do not think it will be issue .Make sure that both the FERT are not similar  otheriwse it will be recursive.
    Regards
    JH

  • IPhone picks up Notes address /o=SCD/ou=FOXASIA/cn= etc... from Outlook

    I am trying to trouble shoot just one small problem with iPhone Contact sync with Exchange...
    [Otherwise, Sync works just fine with Outlook 2003]
    Contacts are captured from the Exchange Server Global Address Book to my Contacts in
    Outlook 2003, then synced with iPhone.
    iPhone picks up the /o=SCD/ou=FOXASIA/cn=Recipients/cn=tterrenz address, not the [email protected] address from Contacts.
    Of course, this Lotus Notes address is rejected by my ISP [Telstra] outgoing mail server...
    If I delete the Notes address, and renter the Internet address on iPhone, it gets over written by Outloook Contacts on the next sync...
    I can create a new entry in Outlook or iPhone, by laboriously reentering all of the data, but spare me, I have several hundred such entries...
    Robert McInnes

    Hello,
    Since the issue also happens on the user's mobility, it can be more than a Entrouge client side issue.
    The first thing come to my mind is the nichname cache which still resides on the user's mailbox. Please try clearing it up and see if it works.
    Thanks,
    Simon Wu
    TechNet Community Support

  • Type2 SCD attributes not shown correctly across subject areas

    User259188     
    March 21, 2012 2:04 AM
    Type2 SCD attributes not shown correctly across subject areas
    Hi,
    The issue is that Type2 SCD attributes are showing the old value when used outside the domain of Type2 SCD dimension.
    For example, if we try to display the value of Type2 SCD attribute from Contact dimension in Opportunities subject area we get the old value instead of current one.
    The reason is that Revenue fact table which is used between Contact and Opportunities dimensions is keeping the old value of Contact ROW_WID.
    Is there a suggested / recommended approach on how to solve this ?
    Would adding the Contact INTEGRATION_ID in Revenue fact table and using it for join instead of ROW_WID, while filtering out on current flag be a best practice ?
    Please advise
    Boris

    Hi Boris,
    to understand how PR_CONTACT_WID is populated on the W_REVN_F, you must use Informatica (PowerCenter Designer) and view the backward link path.
    You could see that PR_CONTACT_WID is search in the Lookup LKP_W_PARTY_PER_D_With_Geo_Wid (mapplet mplt_SIL_RevenueFact) :
    - table W_PARTY_PER_D
    - Query : SELECT
    LOOKUP_TABLE.ROW_WID as ROW_WID,
    LOOKUP_TABLE.GEO_WID as GEO_WID,
    LOOKUP_TABLE.INTEGRATION_ID as INTEGRATION_ID,
    LOOKUP_TABLE.DATASOURCE_NUM_ID as DATASOURCE_NUM_ID,
    LOOKUP_TABLE.EFFECTIVE_FROM_DT as EFFECTIVE_FROM_DT,
    LOOKUP_TABLE.EFFECTIVE_TO_DT as EFFECTIVE_TO_DT
    FROM
    W_PARTY_PER_D LOOKUP_TABLE, W_REVN_FS
    WHERE W_REVN_FS.PR_CONTACT_ID = LOOKUP_TABLE.INTEGRATION_ID
    AND W_REVN_FS.DATASOURCE_NUM_ID = LOOKUP_TABLE.DATASOURCE_NUM_ID
    ORDER BY
    LOOKUP_TABLE.DATASOURCE_NUM_ID,
    LOOKUP_TABLE.INTEGRATION_ID,
    LOOKUP_TABLE.EFFECTIVE_FROM_DT,
    +LOOKUP_TABLE.EFFECTIVE_TO_DT --+
    - Condition : EFFECTIVE_FROM_DT <= IN_DATE AND EFFECTIVE_TO_DT > IN_DATE
    So your value for PR_CONTACT_WID is dependent of the value of IN_DATE ( --> IIF(ISNULL(CLOSE_DT), EXCH_DT, CLOSE_DT)).
    You must verify for one record where you think there is an issue the CLOSE_DT and EXCH_DT on the table W_REVN_F (CLOSE_DT and U_RVN_EXCH_DT)
    Hope it helps,
    Benoît

  • Implimenting SCD Type 2 using SQL Merge

    Hello , 
    I'm working on implimenting SCD type 2 to keep track of changes in dim_A with fields as
    Table A
    VQ_dim_Id , VQ_Name, Contact_Type , Contact_Type, Center_Node_Id , Sed_id , Eed_Id , Insert_date, IsCurrent
    Table B
    CT_Number, Virtual_Queue , Center_Node_ID , Center, Contact_Type.
    Table B acts as source to determine changes for Updates and inserts for Table A .  with join condition on VQ_Name and Virtual_Queue ( Which is bad but business rules have no way to determined by ID)
    my quesiton is I can update VQ_Name , Contact_Type , Center_Node_Id from Source (table B) , Is there any best practice in place where I can insert EED_Id, SED_id as well in case they are missing in the source... any code snippet to impliment SCD with this
    kinda functionality helpful !
    Thank you ,
    Vishal. 

    You can use
    WHEN NOT MATCHED THEN
    INSERT .......
    A best example for SCD type 2 Merge join can be found here...
    http://www.mssqltips.com/sqlservertip/2883/using-the-sql-server-merge-statement-to-process-type-2-slowly-changing-dimensions/
    Please mark as answer, if this post helped you solve the issue.
    Good Luck :) .. visit www.sqlsaga.com for more t-sql code snippets and BI related how to articles.

  • SCD type 2 using merge

    Hi ,
    I'm trying to impliment SCD type 2 using Merge but unlike typical Merge where you have target and source table,  my Inserts come from one table and updates/changes are determined from another table.. I have issue with updates.
    below is structure of three tables :
    Dimension Table : 
     VQ_id, VQ_name,
    contact_type, center_node_id,
    sed_id, eed_id,
    IsCurrent, insert_date  
    VQ_Id is dimension ID based on which Inserts and undates are determined.
    VQ_Name : type 1 change
    Contact_type , Center_node_ID : type 2 changes
    is Current : flag
    sed_id , eed_id are start and end effective date ID's
    Insert table :
    VQ_id,VQ_Name ,Contact_Type , Center_node_ID , Sed_id , eed_id , Insert_date
    from the above table, based on VQ_ID , new records are determined .
    Updates/history records :
    Type 2 changes are tracked based on below table..
    VQ_ID, contact_type,
    center_node_id, Start_Effective_Date,
    CT_ID, Submit_Date
    Based on VQ_ID ,  contact_type, center_node_id,
    Start_Effective_Date , end effective date are determined.
    Any help in this regard is appreciated...
    Thanks ,
    Vishal.

    -- This is dimension table
    CREATE TABLE [dbo].[tblSwDM_dim_VQ](
    [VQ_dim_id] [int] IDENTITY(1,1) NOT NULL,
    [VQ_id] [int] NOT NULL,
    [VQ_name] [varchar](50) NOT NULL,
    [contact_type] [varchar](50) NULL,
    [center_node_id] [int] NULL,
    [sed_id] [int] NULL,
    [eed_id] [int] NULL,
    [IsCurrent] [bit] NOT NULL,
    [insert_date] [datetime] NULL,
    [Start_Effective_Date] AS (CONVERT([datetime],CONVERT([varchar](8),[sed_id],(0)),(0))),
    [End_Effective_Date] AS (CONVERT([datetime],CONVERT([varchar](8),[eed_id],(0)),(0))),
    CONSTRAINT [Pk_tblswDM_dim_VQ] PRIMARY KEY CLUSTERED
    [VQ_dim_id] ASC
    )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
    ) ON [PRIMARY]
    -- THis ifrom where updates/type2 changes would be loaded
    CREATE TABLE [dbo].[tblSwDM_stg_change_control_next_gen](
    [row_id] [int] IDENTITY(1,1) NOT NULL,
    [VQ_id] [int] NOT NULL,
    [contact_type] [varchar](50) NOT NULL,
    [center_node_id] [int] NOT NULL,
    [Start_Effective_Date] [datetime] NOT NULL,
    [CT_ID] [int] NULL,
    [Submit_Date] [datetime] NOT NULL,
    [isValid] [bit] NULL,
    [Remarks] [varchar](100) NULL
    ) ON [PRIMARY]
    Example...
    for a Record in dimention table... [dbo].[tblSwDM_dim_VQ]
    Before Updates :
    VQ_dim_id VQ_id VQ_name contact_type center_node_id sed_id eed_id IsCurrent insert_date Start_Effective_Date End_Effective_Date
    2203 376946 Fraud_Span_Det_VQ RFD USCC Detection 4536 20131018 20700101 1 2014-03-21 12:02:42.750 2013-10-18 00:00:00.000 2070-01-01 00:00:00.000
    Final Result :
    VQ_dim_id VQ_id VQ_name contact_type center_node_id sed_id eed_id IsCurrent insert_date Start_Effective_Date End_Effective_Date
    2203 376946 Fraud_Span_Det_VQ RFD USCC Detection 4536 20131018 20140423 0 2014-03-21 12:02:42.750 2013-10-18 00:00:00.000 2014-04-23 00:00:00.000
    2605 376946 Fraud_Span_Det_VQ RFS USCC Spanish 4537 20140424 20700101 1 2014-05-07 11:51:00.543 2014-04-24 00:00:00.000 2070-01-01 00:00:00.000

Maybe you are looking for

  • Hard drive failure on my Pavillion DV6500

    Howdy, I have a 2.5 year old HP Pavillion DV6500 with hard drive failure. I can turn the laptop on, but right before Vista starts I get this error message telling me that something is wrong with the hard disk. I've tried running System Recovery throu

  • Km transport related problem

    Hello guys,             I have done the offline transport of km data, and as the SAP documentation says only ACL's get transported. The problem is the we are not getting the collaboration tab in folder or document details property. We are only gettin

  • HT2506 How do I compress a Preview file when there is not a "save as" option?

    I am trying to compress a jpg or a pdf in preview. I have read the answer: save as, etc. My Preview doesn't have a "save as" option, just "save". Is there another way to compress it?

  • PDF layers not exporting

    Hi, I created a document in Indesign with layers.  I have that in acrobat and created buttons to show the different layers.  I click a button, and that layer shows up.  Great.  But when I submit or save the pdf, the layers do not show up visible upon

  • VIVADO 2015.2 IP Packager ruins all bool type parameters

    Hi All, As subject: in one IP of ours, there are 3 boolean parameters (last packaged with IPI 2014.4). The component.xml is attached for Xilinx's comments, as you can see, the parameter is defined properly. When I open the IP Package from the VIVADO