Surrogate keys -- which field to be used?

Hello,
I am wondering what field would be best suited to be used as surrogate key for a data warehouse. Since my fact table is likely to have hundreds of thousands of records, I am thinking that uniqueidentifier makes more sense than some type of integer.
Any thoughts on this?
Also I am designing my DW (I am really starting with a data-mart) with a lot of data coming from Dynamics CRM and I was wondering if a surrogate key is really necessary if we are not going to ever delete records from the data sources.
Any advice and insights is greatly appreciated.
Regards,
P.

Since my fact table is likely to have hundreds of thousands of records, I am thinking that uniqueidentifier makes more sense than some type of integer.
Hello,
100 K is very less on data. Integer data type performs best is SQL Server, much better the GUID's and with type integer you can handle 4 billion values.
Olaf Helper
[ Blog] [ Xing] [ MVP]

Similar Messages

  • Which fields taken for use in CD-Text info?

    I've been burning CDs with CD-Text using Toast for a while, and I have a very exact way how I want the track info to appear on my CD-Rs. I've upgraded from Panther to Tiger, and now that the Include CD-Text option is available, which fields, exactly, does it take from, and how does it arrange them when I see them when I insert an audio CD-R into my CD player? Thanks very much. Peace.

    You're right, but I'm a little under the gun with my employer to get something out there, asap, and I unfortunately have a full time job that doesn't allow me to commit a block of time to finish the text in one shot.

  • Building dimensions that are based on surrogate keys

    Hi -
    I am new to AWM and have a question.
    I read the docs, but I still do not understand how to build a cube using AWM.
    So we have a DW with dimensions and fact tables. The dimension tables use surrogate keys.
    The fact table uses the surrogate keys of the dimensions.
    I want to define the time dimension in AWM.
    The unique key for the dimension is the surrogate key (time_key).
    In AWM I defined levels: day, month and year.
    Would the hierarchy for the day level be:
    time_key -> day?
    Thanks,
    Frank

    Thankyou so much.
    now when I try that here is the error that I get for that
    line:
    1118: Implicit coercion of a value with static type
    flash.display:DisplayObject to a possibly unrelated type
    flash.display:MovieClip.
    I've placed a zipfile with my FLA, .as and .xml here:
    http://bigfins.com/temp/test5xml.zip
    The actionscript alone is below.
    Thankyou again for any assistance.

  • Which field in sales order lines for customer reference no.

    Dear Experts,
    Which field should I use for customer reference no. in sales order LINES?
    These values can not be duplicated in each sales order just like NumatCard in sales orders.
    regards,
    Kim

    Hi Gun Tae Kim...
    Select The User defined fields
    Select The Marketing Document and ADD THE REQUIRED FIELD IN THE ROW AND CHECK
    CHECK WITH THE LINK FOR DETAILED INFORMATION
    http://www.pioneerb1.com/wp-content/uploads/2012/06/How-to-Create-User-Defined-Fields-and-Tables.pdf
    HOPE HELPFUL
    Regards
    Kennedy

  • Why does BW use surrogate keys ?

    Hi,
    can anyone answer me in 1 sentence:
    Why dos BW uses surrogate / artifical keys ?
    Its not faster while querying - line items are faster & y need query more tables.
    Its not faster while loading - surrogate keys need to be looked up and build up.
    ThanXs
    Martin

    A database don't care if it's numeric or not. Index access is index access and that is what matters. But talking about indexes. There is less index'es to maintain when you use surrogates, otherwise you should have an index on each characteristic in the fact table, and it could be a lot. Also there may be a historical technical reason, like the number of key fields available on a table. Remember that SAP is trying to be DB vendor independent so if a supported DB only accepts say 16 key fields, then you need to design you application for that.
    -Kristian

  • How we generate Surrogate Keys without using identify column

    Hi All,
    How we generate Surrogate Keys without using identify column.
    Regards,
    Manish

    There are various options
    1.IDENTITY columns - simplest to implement
    2. Using NEWID(), NEWSEQUENTIALID() functions (if you want to use GUID values as surrogate keys)
    3. SEQUENCE object (if SQL 2012 and above)
    4. Using custom functions to generate keys yourself
    This is an good article which compares use of GUIDs against integers as surrogate keys
    http://blog.jonathanoliver.com/integers-vs-guids-and-natural-vs-surrogate-keys/
    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

  • How do you know which fields are mandatory while uploading PO using BAPI.

    How do you know which fields are mandatory while uploading PO data using BAPI. in a structure how do you know which fields are mandatory.
    and also, where how do you check that, the BAPI function module is executed.
    Thanks in Advance.
    Naveen.

    hi
    hope it will help you.
    Reward if help.
    REPORT zpo_bapi_purchord_tej.
    DATA DECLARATIONS *
    TYPE-POOLS slis.
    TYPES: BEGIN OF ty_table,
    v_legacy(8),
    vendor TYPE bapimepoheader-vendor,
    purch_org TYPE bapimepoheader-purch_org,
    pur_group TYPE bapimepoheader-pur_group,
    material TYPE bapimepoitem-material,
    quantity(13),
    delivery_date TYPE bapimeposchedule-delivery_date,
    net_price(23),
    plant TYPE bapimepoitem-plant,
    END OF ty_table.
    TYPES: BEGIN OF ty_alv,
    v_legs(8),
    success(10),
    v_legf(8),
    END OF ty_alv.
    TYPES: BEGIN OF ty_alv1,
    v_legf1(8),
    v_msg(500),
    END OF ty_alv1.
    *-----Work area declarations.
    DATA: x_table TYPE ty_table,
    x_header TYPE bapimepoheader,
    x_headerx TYPE bapimepoheaderx,
    x_item TYPE bapimepoitem,
    x_itemx TYPE bapimepoitemx,
    x_sched TYPE bapimeposchedule,
    x_schedx TYPE bapimeposchedulx,
    x_commatable(255),
    x_alv TYPE ty_alv,
    x_alv1 TYPE ty_alv1,
    x_alv2 TYPE ty_alv1.
    *-----Internal table declarations.
    DATA: it_table TYPE TABLE OF ty_table,
    it_commatable LIKE TABLE OF x_commatable,
    it_item TYPE TABLE OF bapimepoitem,
    it_itemx TYPE TABLE OF bapimepoitemx,
    it_sched TYPE TABLE OF bapimeposchedule,
    it_schedx TYPE TABLE OF bapimeposchedulx,
    it_alv TYPE TABLE OF ty_alv,
    it_alv1 TYPE TABLE OF ty_alv1,
    it_alv2 TYPE TABLE OF ty_alv1.
    DATA: po_number TYPE bapimepoheader-po_number,
    x_return TYPE bapiret2,
    it_return TYPE TABLE OF bapiret2,
    v_file TYPE string,
    v_temp(8),
    v_succsount TYPE i VALUE 0,
    v_failcount TYPE i VALUE 0,
    v_total TYPE i.
    DATA: v_temp1(5) TYPE n VALUE 0.
    DATA: x_event TYPE slis_t_event,
    x_fieldcat TYPE slis_t_fieldcat_alv,
    x_list_header TYPE slis_t_listheader,
    x_event1 LIKE LINE OF x_event,
    x_layout1 TYPE slis_layout_alv,
    x_variant1 TYPE disvariant,
    x_repid2 LIKE sy-repid.
    DATA : it_fieldcat TYPE TABLE OF slis_t_fieldcat_alv.
    SELECTION-SCREEN *
    SELECTION-SCREEN BEGIN OF BLOCK v_b1 WITH FRAME.
    *-----To fetch the flat file.
    PARAMETERS: p_file TYPE rlgrap-filename.
    SELECTION-SCREEN END OF BLOCK v_b1.
    AT SELECTION-SCREEN *
    AT SELECTION-SCREEN.
    IF p_file IS INITIAL.
    MESSAGE text-001 TYPE 'E'.
    ENDIF.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
    *-----To use F4 help to find file path.
    CALL FUNCTION 'F4_FILENAME'
    EXPORTING
    program_name = syst-cprog
    dynpro_number = syst-dynnr
    IMPORTING
    file_name = p_file.
    v_file = p_file.
    START-OF-SELECTION *
    START-OF-SELECTION.
    PERFORM gui_upload.
    LOOP AT it_table INTO x_table.
    PERFORM header_details.
    v_temp = x_table-v_legacy.
    LOOP AT it_table INTO x_table WHERE v_legacy = v_temp.
    PERFORM lineitem.
    PERFORM schedule.
    ENDLOOP.
    DELETE it_table WHERE v_legacy = v_temp.
    PERFORM bapicall.
    MOVE po_number TO x_alv-success.
    APPEND x_alv TO it_alv.
    CLEAR x_alv.
    *-----To clear the item details in internal table after the operation for a header.
    REFRESH: it_item,
    it_itemx,
    it_sched,
    it_schedx.
    CLEAR: v_temp1.
    ENDLOOP.
    v_total = v_succsount + v_failcount.
    PERFORM display_alv.
    FORM GUI_UPLOAD *
    FORM gui_upload .
    CALL FUNCTION 'GUI_UPLOAD'
    EXPORTING
    filename = v_file
    filetype = 'ASC'
    TABLES
    data_tab = it_commatable
    EXCEPTIONS
    file_open_error = 1
    file_read_error = 2
    no_batch = 3
    gui_refuse_filetransfer = 4
    invalid_type = 5
    no_authority = 6
    unknown_error = 7
    bad_data_format = 8
    header_not_allowed = 9
    separator_not_allowed = 10
    header_too_long = 11
    unknown_dp_error = 12
    access_denied = 13
    dp_out_of_memory = 14
    disk_full = 15
    dp_timeout = 16
    OTHERS = 17
    IF sy-subrc = 0.
    *-----To fetch the comma seperated flat file into an internal table.
    LOOP AT it_commatable INTO x_commatable.
    IF x_commatable IS NOT INITIAL.
    SPLIT x_commatable AT ',' INTO
    x_table-v_legacy
    x_table-vendor
    x_table-purch_org
    x_table-pur_group
    x_table-material
    x_table-quantity
    x_table-delivery_date
    x_table-net_price
    x_table-plant.
    APPEND x_table TO it_table.
    ENDIF.
    CLEAR x_table.
    ENDLOOP.
    ENDIF.
    ENDFORM. " gui_upload
    FORM HEADER_DETAILS *
    FORM header_details .
    MOVE 'NB' TO x_header-doc_type.
    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
    EXPORTING
    input = x_table-vendor
    IMPORTING
    output = x_table-vendor
    MOVE x_table-vendor TO x_header-vendor.
    MOVE x_table-purch_org TO x_header-purch_org.
    MOVE x_table-pur_group TO x_header-pur_group.
    x_headerx-doc_type = 'X'.
    x_headerx-vendor = 'X'.
    x_headerx-purch_org = 'X'.
    x_headerx-pur_group = 'X'.
    ENDFORM. " header_details
    FORM LINEITEM *
    FORM lineitem .
    v_temp1 = v_temp1 + 10.
    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
    EXPORTING
    input = v_temp1
    IMPORTING
    output = v_temp1.
    MOVE v_temp1 TO x_item-po_item.
    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
    EXPORTING
    input = x_table-material
    IMPORTING
    output = x_table-material.
    MOVE x_table-material TO x_item-material.
    MOVE x_table-quantity TO x_item-quantity.
    MOVE x_table-net_price TO x_item-net_price.
    MOVE x_table-plant TO x_item-plant.
    x_itemx-po_item = v_temp1.
    x_itemx-material = 'X'.
    x_itemx-quantity = 'X'.
    x_itemx-net_price = 'X'.
    x_itemx-plant = 'X'.
    APPEND x_item TO it_item.
    APPEND x_itemx TO it_itemx.
    CLEAR: x_item, x_itemx.
    ENDFORM. " lineitem1
    FORM SCHEDULE *
    FORM schedule .
    MOVE x_table-delivery_date TO x_sched-delivery_date.
    MOVE v_temp1 TO x_sched-po_item.
    x_schedx-delivery_date = 'X'.
    x_schedx-po_item = v_temp1.
    APPEND x_sched TO it_sched.
    APPEND x_schedx TO it_schedx.
    CLEAR: x_sched, x_schedx.
    ENDFORM. " schedule
    FORM BAPICALL *
    FORM bapicall .
    CALL FUNCTION 'BAPI_PO_CREATE1'
    EXPORTING
    poheader = x_header
    poheaderx = x_headerx
    IMPORTING
    exppurchaseorder = po_number
    TABLES
    return = it_return
    poitem = it_item
    poitemx = it_itemx
    poschedule = it_sched
    poschedulex = it_schedx.
    IF po_number IS NOT INITIAL.
    v_succsount = v_succsount + 1.
    MOVE x_table-v_legacy TO x_alv-v_legs.
    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
    ELSE.
    v_failcount = v_failcount + 1.
    MOVE x_table-v_legacy TO x_alv-v_legf.
    MOVE x_table-v_legacy TO x_alv1-v_legf1.
    LOOP AT it_return INTO x_return.
    IF x_alv1-v_msg IS INITIAL.
    MOVE x_return-message TO x_alv1-v_msg.
    ELSE.
    CONCATENATE x_alv1-v_msg x_return-message INTO x_alv1-v_msg SEPARATED BY space.
    ENDIF.
    ENDLOOP.
    APPEND x_alv1 TO it_alv1.
    CLEAR x_alv1.
    ENDIF.
    ENDFORM. " bapicall
    FORM DISPLAY_ALV *
    FORM display_alv .
    PERFORM x_list_header.
    PERFORM build_fieldcat CHANGING x_fieldcat.
    x_repid2 = sy-repid.
    x_event1-name = 'TOP_OF_PAGE'.
    x_event1-form = 'TOP_OF_PAGE'.
    APPEND x_event1 TO x_event.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
    i_callback_program = x_repid2
    is_layout = x_layout1
    it_fieldcat = x_fieldcat
    i_callback_user_command = 'USER_COMMAND'
    i_callback_top_of_page = 'TOP_OF_PAGE'
    i_save = 'A'
    is_variant = x_variant1
    it_events = x_event
    TABLES
    t_outtab = it_alv
    EXCEPTIONS
    program_error = 1
    OTHERS = 2.
    IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
    ENDFORM. " display_master_data
    FORM USER_COMMAND *
    FORM user_command USING ucomm LIKE sy-ucomm selfield
    TYPE slis_selfield.
    READ TABLE it_alv INTO x_alv INDEX selfield-tabindex.
    CLEAR : x_alv2,it_alv2[].
    LOOP AT it_alv1 INTO x_alv1 WHERE v_legf1 = x_alv-v_legf.
    x_alv2 = x_alv1.
    APPEND x_alv2 TO it_alv2 .
    ENDLOOP.
    DATA : it_fieldcat TYPE slis_t_fieldcat_alv.
    DATA : x3_fieldcat LIKE LINE OF it_fieldcat.
    CLEAR : x3_fieldcat,it_fieldcat[].
    CLEAR x3_fieldcat.
    x3_fieldcat-col_pos = '1'.
    x3_fieldcat-fieldname = 'V_LEGF1'.
    x3_fieldcat-reptext_ddic = text-111.
    x3_fieldcat-ref_tabname = 'IT_ALV2'.
    APPEND x3_fieldcat TO it_fieldcat.
    CLEAR x3_fieldcat.
    CLEAR x3_fieldcat.
    x3_fieldcat-col_pos = '1'.
    x3_fieldcat-fieldname = 'V_MSG'.
    x3_fieldcat-reptext_ddic = text-112.
    x3_fieldcat-ref_tabname = 'IT_ALV2'.
    APPEND x3_fieldcat TO it_fieldcat.
    CLEAR x3_fieldcat.
    x_layout1-colwidth_optimize = 'X'.
    x_layout1-zebra = 'X'.
    IF it_alv2[] IS NOT INITIAL.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
    i_callback_program = x_repid2
    is_layout = x_layout1
    it_fieldcat = it_fieldcat
    i_save = 'A'
    i_callback_top_of_page = 'TOP'
    is_variant = x_variant1
    it_events = x_event
    TABLES
    t_outtab = it_alv2
    EXCEPTIONS
    program_error = 1
    OTHERS = 2.
    ENDIF.
    ENDFORM.
    FORM USER_COMMAND *
    FORM top.
    CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
    EXPORTING
    it_list_commentary = 'Commentry'.
    ENDFORM.
    FORM BUILD_FIELDCAT *
    FORM build_fieldcat CHANGING et_fieldcat TYPE slis_t_fieldcat_alv.
    DATA: x1_fieldcat TYPE slis_fieldcat_alv.
    CLEAR x1_fieldcat.
    x1_fieldcat-col_pos = '1'.
    x1_fieldcat-fieldname = 'V_LEGS'.
    x1_fieldcat-reptext_ddic = text-108.
    x1_fieldcat-ref_tabname = 'IT_ALV'.
    APPEND x1_fieldcat TO et_fieldcat.
    CLEAR x1_fieldcat.
    x1_fieldcat-col_pos = '2'.
    x1_fieldcat-fieldname = 'SUCCESS'.
    x1_fieldcat-key = 'X'.
    x1_fieldcat-reptext_ddic = text-109.
    x1_fieldcat-ref_tabname = 'IT_ALV'.
    APPEND x1_fieldcat TO et_fieldcat.
    CLEAR x1_fieldcat.
    x1_fieldcat-col_pos = '3'.
    x1_fieldcat-fieldname = 'V_LEGF'.
    x1_fieldcat-key = 'X'.
    x1_fieldcat-reptext_ddic = text-110.
    x1_fieldcat-ref_tabname = 'IT_ALV'.
    APPEND x1_fieldcat TO et_fieldcat.
    CLEAR x1_fieldcat.
    ENDFORM. " build_fieldcat
    FORM BUILD_LIST_HEADER *
    FORM x_list_header.
    DATA: x_list_header1 TYPE slis_listheader.
    *-----List Header: type H
    CLEAR x_list_header1 .
    x_list_header1-typ = 'H'.
    x_list_header1-info = text-105.
    APPEND x_list_header1 TO x_list_header.
    *-----List Key: type S
    x_list_header1-typ = 'S'.
    x_list_header1-key = text-106.
    x_list_header1-info = v_total.
    APPEND x_list_header1 TO x_list_header.
    *-----List Key: Type S
    CLEAR x_list_header1 .
    x_list_header1-typ = 'S'.
    x_list_header1-key = text-107.
    x_list_header1-info = v_succsount.
    APPEND x_list_header1 TO x_list_header.
    ENDFORM. " build_list_header
    FORM TOP_OF_PAGE *
    FORM top_of_page.
    CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
    EXPORTING
    it_list_commentary = x_list_header.
    ENDFORM. " TOP_OF_PAGE

  • Unable to modify a XML node which is a SimpleType using a Typed XML field.

    Hello,
    I have an XSD schema that uses SimpleTypes.  When I attempt to modify a node in an Schema typed XML field, which has a schema using simpletypes, I receive the error:  XQuery [modify()]: The value is of type "xs:string", which is not a
    subtype of the expected type "<anonymous>"
    To reproduce the problem use the following information:
    SCHEMA:
    <?xml version="1.0" encoding="UTF-8"?>
    <xs:schema xmlns:ns1="http://testschema" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:vc="http://www.w3.org/2007/XMLSchema-versioning" targetNamespace="http://testschema" elementFormDefault="qualified" attributeFormDefault="unqualified" vc:minVersion="1.1">
    <xs:element name="Test">
    <xs:annotation>
    <xs:documentation>Comment describing your root element</xs:documentation>
    </xs:annotation>
    <xs:complexType>
    <xs:sequence>
    <xs:element name="SAPCode">
    <xs:annotation>
    <xs:documentation>Customer Number for Delivery Organization</xs:documentation>
    </xs:annotation>
    <xs:simpleType>
    <xs:restriction base="xs:string">
    <xs:length value="10"/>
    </xs:restriction>
    </xs:simpleType>
    </xs:element>
    <xs:element name="OrganizationName">
    <xs:annotation>
    <xs:documentation>Name of Organization</xs:documentation>
    </xs:annotation>
    <xs:simpleType>
    <xs:restriction base="xs:string">
    <xs:maxLength value="100"/>
    </xs:restriction>
    </xs:simpleType>
    </xs:element>
    <xs:element name="AttentionTo" minOccurs="0">
    <xs:annotation>
    <xs:documentation>Attention to Recepient for the delivery</xs:documentation>
    </xs:annotation>
    <xs:simpleType>
    <xs:restriction base="xs:string">
    <xs:maxLength value="150" fixed="false"/>
    </xs:restriction>
    </xs:simpleType>
    </xs:element>
    <xs:element name="Address1">
    <xs:simpleType>
    <xs:restriction base="xs:string">
    <xs:maxLength value="150"/>
    </xs:restriction>
    </xs:simpleType>
    </xs:element>
    <xs:element name="Address2" minOccurs="0">
    <xs:simpleType>
    <xs:restriction base="xs:string">
    <xs:maxLength value="150"/>
    </xs:restriction>
    </xs:simpleType>
    </xs:element>
    <xs:element name="Address3" minOccurs="0">
    <xs:simpleType>
    <xs:restriction base="xs:string">
    <xs:maxLength value="150"/>
    </xs:restriction>
    </xs:simpleType>
    </xs:element>
    <xs:element name="City">
    <xs:simpleType>
    <xs:restriction base="xs:string">
    <xs:maxLength value="100"/>
    </xs:restriction>
    </xs:simpleType>
    </xs:element>
    <xs:element name="StateProvince">
    <xs:simpleType>
    <xs:restriction base="xs:string">
    <xs:maxLength value="100"/>
    </xs:restriction>
    </xs:simpleType>
    </xs:element>
    <xs:element name="PostalCode">
    <xs:simpleType>
    <xs:restriction base="xs:string">
    <xs:maxLength value="20"/>
    </xs:restriction>
    </xs:simpleType>
    </xs:element>
    <xs:element name="Country">
    <xs:simpleType>
    <xs:restriction base="xs:string">
    <xs:length value="2"/>
    </xs:restriction>
    </xs:simpleType>
    </xs:element>
    <xs:element name="Phone" minOccurs="0">
    <xs:simpleType>
    <xs:restriction base="xs:string">
    <xs:maxLength value="50"/>
    </xs:restriction>
    </xs:simpleType>
    </xs:element>
    <xs:element name="EmailAddress" minOccurs="0">
    <xs:simpleType>
    <xs:restriction base="xs:string">
    <xs:maxLength value="200"/>
    </xs:restriction>
    </xs:simpleType>
    </xs:element>
    </xs:sequence>
    </xs:complexType>
    </xs:element>
    </xs:schema>
    The T-SQL That produces the error:
    DECLARE
    @vx_Test xml (CONTENT [dbo].[Test]),
    @vs_ShipToAttentionTo NVARCHAR(50)
    SET
    @vx_Test = N'<ns0:Test xmlns:ns0="http://testschema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <ns0:SAPCode>1234567890</ns0:SAPCode>
    <ns0:OrganizationName>Test Org</ns0:OrganizationName>
    <ns0:AttentionTo>Test Person</ns0:AttentionTo>
    <ns0:Address1>123 Main Street</ns0:Address1>
    <ns0:City>Test City</ns0:City>
    <ns0:StateProvince>IL</ns0:StateProvince>
    <ns0:PostalCode>12345</ns0:PostalCode>
    <ns0:Country>US</ns0:Country>
    </ns0:Test>'
    SET
    @vs_ShipToAttentionTo = 'New Attention To'
    SET @vx_Test.modify('declare namespace ns0="http://testschema";
    replace value of (/ns0:Test[1]/ns0:AttentionTo) with sql:variable("@vs_ShipToAttentionTo")');
    -- This would be how I would reference it if I was modifiying the XML in a typed XML column in a table.
    WITH XMLNAMESPACES('http://testschema' AS ns0)
    UPDATE TestItems
    SET TestXML.modify('replace value of (/ns0:Test[1]/ns0:AttentionTo) with sql:variable("@vs_ShipToAttentionTo")')
    SELECT @vx_Test
    How can I make this work.  In this example I am using a typed XML variable, but I really want to do this in a table update.
    Thanks,
    Kent

    Try the change below.  What I did was to create a named simple type for the AttentionTo node.  Here is my understanding (based on this working).  Because you have a simpleType the node cannot accept just any string, it has to be a string of
    the type in the simpleType.  That simpleType has no name (thus anonymous). 
    What I did was to create a named simpleType and used that simpleType as the type for the AttentionTo element.  Then in my XQuery, I cast the value to the name of that type (AttentionToType in my example).
    CREATE xml schema collection Test as '<?xml version="1.0" encoding="UTF-8"?>
    <xs:schema xmlns:ns1="http://testschema" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:vc="http://www.w3.org/2007/XMLSchema-versioning" targetNamespace="http://testschema" elementFormDefault="qualified" attributeFormDefault="unqualified" vc:minVersion="1.1">
    <xs:element name="Test">
    <xs:annotation>
    <xs:documentation>Comment describing your root element</xs:documentation>
    </xs:annotation>
    <xs:complexType>
    <xs:sequence>
    <xs:element name="SAPCode">
    <xs:annotation>
    <xs:documentation>Customer Number for Delivery Organization</xs:documentation>
    </xs:annotation>
    <xs:simpleType>
    <xs:restriction base="xs:string">
    <xs:length value="10"/>
    </xs:restriction>
    </xs:simpleType>
    </xs:element>
    <xs:element name="OrganizationName">
    <xs:annotation>
    <xs:documentation>Name of Organization</xs:documentation>
    </xs:annotation>
    <xs:simpleType>
    <xs:restriction base="xs:string">
    <xs:maxLength value="100"/>
    </xs:restriction>
    </xs:simpleType>
    </xs:element>
    <xs:element name="AttentionTo" minOccurs="0" type="ns1:AttentionToType">
    <xs:annotation>
    <xs:documentation>Attention to Recepient for the delivery</xs:documentation>
    </xs:annotation>
    </xs:element>
    <xs:element name="Address1">
    <xs:simpleType>
    <xs:restriction base="xs:string">
    <xs:maxLength value="150"/>
    </xs:restriction>
    </xs:simpleType>
    </xs:element>
    <xs:element name="Address2" minOccurs="0">
    <xs:simpleType>
    <xs:restriction base="xs:string">
    <xs:maxLength value="150"/>
    </xs:restriction>
    </xs:simpleType>
    </xs:element>
    <xs:element name="Address3" minOccurs="0">
    <xs:simpleType>
    <xs:restriction base="xs:string">
    <xs:maxLength value="150"/>
    </xs:restriction>
    </xs:simpleType>
    </xs:element>
    <xs:element name="City">
    <xs:simpleType>
    <xs:restriction base="xs:string">
    <xs:maxLength value="100"/>
    </xs:restriction>
    </xs:simpleType>
    </xs:element>
    <xs:element name="StateProvince">
    <xs:simpleType>
    <xs:restriction base="xs:string">
    <xs:maxLength value="100"/>
    </xs:restriction>
    </xs:simpleType>
    </xs:element>
    <xs:element name="PostalCode">
    <xs:simpleType>
    <xs:restriction base="xs:string">
    <xs:maxLength value="20"/>
    </xs:restriction>
    </xs:simpleType>
    </xs:element>
    <xs:element name="Country">
    <xs:simpleType>
    <xs:restriction base="xs:string">
    <xs:length value="2"/>
    </xs:restriction>
    </xs:simpleType>
    </xs:element>
    <xs:element name="Phone" minOccurs="0">
    <xs:simpleType>
    <xs:restriction base="xs:string">
    <xs:maxLength value="50"/>
    </xs:restriction>
    </xs:simpleType>
    </xs:element>
    <xs:element name="EmailAddress" minOccurs="0">
    <xs:simpleType>
    <xs:restriction base="xs:string">
    <xs:maxLength value="200"/>
    </xs:restriction>
    </xs:simpleType>
    </xs:element>
    </xs:sequence>
    </xs:complexType>
    </xs:element>
    <xs:simpleType name="AttentionToType">
    <xs:restriction base="xs:string">
    <xs:maxLength value="150" fixed="false"/>
    </xs:restriction>
    </xs:simpleType>
    </xs:schema>';
    go
    DECLARE
    @vx_Test xml (CONTENT dbo.Test),
    @vs_ShipToAttentionTo nvarchar(50)
    SET
    @vx_Test = N'<ns0:Test xmlns:ns0="http://testschema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <ns0:SAPCode>1234567890</ns0:SAPCode>
    <ns0:OrganizationName>Test Org</ns0:OrganizationName>
    <ns0:AttentionTo>Test Person</ns0:AttentionTo>
    <ns0:Address1>123 Main Street</ns0:Address1>
    <ns0:City>Test City</ns0:City>
    <ns0:StateProvince>IL</ns0:StateProvince>
    <ns0:PostalCode>12345</ns0:PostalCode>
    <ns0:Country>US</ns0:Country>
    </ns0:Test>'
    SET
    @vs_ShipToAttentionTo = 'New Attention To'
    SET @vx_Test.modify('declare namespace ns0="http://testschema";
    replace value of (/ns0:Test[1]/ns0:AttentionTo) with sql:variable("@vs_ShipToAttentionTo") cast as ns0:AttentionToType?');
    -- This would be how I would reference it if I was modifiying the XML in a typed XML column in a table.
    WITH XMLNAMESPACES('http://testschema' AS ns0)
    UPDATE TestItems
    SET TestXML.modify('replace value of (/ns0:Test[1]/ns0:AttentionTo)
    with sql:variable("@vs_ShipToAttentionTo")')
    SELECT @vx_Test
    Russel Loski, MCT, MCSE Data Platform/Business Intelligence. Twitter: @sqlmovers; blog: www.sqlmovers.com

  • Use of Surrogate Key

    In designing table, is it always safe to use surrogate key, say an NUMBER(38) type, generated by a sequence - even a naturally occuring candidate key does exist e.g. student_id?
    What are the considerations when choosing the PK column(s)?

    This is actually situational. Although I personally prefer to use surrogate keys whenever possible, there are valid reasons why natural keys should be preferred in some situations (such as a reference/lookup table for instance). I discuss key strategies at http://www.agiledata.org/essays/dataModeling101.html#AssignKeys and have been meaning to rework this section into its own article one of these days.
    - Scott
    http://www.ambysoft.com/scottAmbler.html

  • I need to use the "apple key" which is, I presume the command key, but I do not have an apple keyboard; is there a key on a logitech keyboard which will serve the purpose?

    I need to use the "Apple key" which I presume is the command key; my computer does not have an apple keyboard; is there a key on a logitech keyboard which will serve the same purpose?

    The "Windows flag" key on PC keyaboard in Commans, "Alt" is option.
    Go to Logitech website to see if they have Mac compatibility software (Logictech Control Center) to make mappings a bit more complex).

  • How we use Surrogate Keys for snowflake dimension

    Hi All,
    my question is - How we use  Surrogate Keys for  snowflake dimension
    i heard from some body Surrogate Keys only work with star schema.
    please correct me if i wrong.
    Regards,
    Manish

    Hi manishcal16PPS,
    According to your description, you can only create natural key in your dimension. But it's not working when using surrogate key. Right?
    In Analysis Services, the snowflake schema of the dimensions are represented by more than one dimension table in other words its takes multiple dimension tables to define a dimension. Surrogate key are just some extra, redundant, unique key based on the
    natural key. So there's no direct relationship or some limitations between surrogate keys and snowflake schema.
    In this scenario, since there's relationship between the two dimensions, you should create natural key. For using natural key or surrogate key. Please refer to an article below:
    Surrogate Key vs. Natural Key
    For understanding star/snowflake schema, please see:
    Understanding Star and Snowflake Schemas 
    Regards,
    Simon Hou
    TechNet Community Support

  • How to use Key Flex Fields in Custom Form

    Dear Members,
    I have developed a custom form.
    In my form there is a search criteria for location.
    When ever user wants to query based on the location ,I want to display Asset Location Key Flexfield so that user can choose the respective segements and search the assets.
    Can any one please tell me what is the procedure to be followed to display Key Flex Fields in the custom forms?
    Your inputs will be of great help to me.
    Thanks in advance.
    Best Regards,
    Arun Reddy.

    Hi,
    Please see the note:730068.1 - How To Invoke a DFF from a custom form
    Thanks,
    Ajikumar G

  • About Surrogate Key and Dimension Key on OWB 10.2

    Hi, everyone.
    I am using OWB 10.2 and I have a question about Surrogate key and Dimension Key.
    I indicated the foreign key as VARCHAR2 type in Fact Table and Dimension Key as VARCHAR2 type is operated as Primary key in Dimension Table. I made Single Level in Dimension Table.
    I know that Dimension Key stores the surrogate ID for dimension and is the primary key of the table. Also, Surrogate ID should be only NUMBER type.
    So, in this case, Surrogate ID is NUMBER type
    Dimension key should be NUMBER type to store the surrogate ID.
    But, Dimension key also should operate the primary to relate Foreign key as VARCHAR2 type.
    How I can solve this confusing condition?
    Please let me know that.
    JWS

    Hi JWS,
    From a SQL point of view it should not be a problem to join a NUMBER field to a VARCHAR2 field because during execution there will be an implicite cast for the NUMBER value to a VARCHAR2 value. See the example below.
       SELECT * FROM DUAL
       WHERE   1 = '1'From an OWB point of view it is not possible to have a Dimension with an NUMBER value Key that has a relation to a VARCHAR2 value Foreign key in a Fact table. This is caused due to the creation of a Fact table in OWB in which the Foreign keys in it are build from de Dimension tables that refer to them.
    You will loose the reference to the Dimension when changing the type of the Foreign Key.
    To resolve this issue I would advise you to use a Sequence that generates your Surrogate Key (NUMBER type) for the Dimension table and store it in the Primary Key Column (VARCHAR2 type).
    When validating the mapping you will get a warning, but when executing this should give no problems.
    Regards,
    Ilona

  • Apex and Natural Vs Surrogate keys

    Hi
    We've been using Apex for a few months now and there's a debate raging in our department over whether we should design our database tables using natural or surrogate (based on Oracle sequences / triggers) keys. Our experience as Apex developers shows that Apex itself looks to lean towards surrogate keys, a few examples are below:
    - When creating forms on reports / tables Apex only allows 2 primary key columns without adding 'extras' in the background (see a previous post of mine).
    - If we have a form on a table and our natural primary keys can be updated, the Apex-created DML statements break, as they look to do the update using the changed key values in the WHERE clause rather than the old ones. The only way around this seems to be to delete the inbuilt DML statements created by Apex and code your own, which is extra work.
    - The Apex sample applications themselves seem to use sequences / surrogate keys.
    What are people's opinions on this? In particular is there any guidance from the Apex development team on which is best to use with Apex?
    Regards
    Antilles

    Hi Andrew,
    As with abots_d, I only use "natural" keys for lookups.
    >
    1. the department names were here for 20 years and they never changed
    >
    But, can you guarantee that they never will? My firm has changed departmental names so many times, it's getting ridiculous! But other things also change over time - consider what happens if a person gets married and changes their name and you've used their previous names as the keys (and consider how much data in other tables may use those keys).
    >
    2. Server names are uniquely generated by special formula in excel to preciously avoid the duplication problem and guarantee the uniqueness within our glamorous bank.
    >
    SQL could probably recreate that formula and Unique Key constraints would handle the rest
    >
    3. no, we are not going to extend this app to cover any other banks
    >
    Given what's happening with the banking industry right now, who can say ;)
    >
    4. PK that means smth ( aka "server name" ) has a meaning, whereas meaningless - has no (business) value
    >
    Why does a bit of data have to have explicit "business value"? I would suggest that a surrogate key is a pointer to a record and allows you to easily create relationships. Once created, the key would never be changed regardless of what happens to the data on its record. Thus, the relationship is maintained. Using personnel (which our firm renamed as "Human Resources" a while back) as an example, it's likely that every employee would have an employee number. Does this number actually mean anything in itself, does it have "business value"? Most likely, it's just a convenient way to identify a person and relate records to them.
    I would suggest that any non-numeric/date keys are relatively slow. As strings, the only way to check for their sort order would be to (A) convert to upper or lower case and (B) perform a string comparison left-to-right across the entire string. There's also the possibility of certain characters appearing in the strings that can cause issues - for example, quotes, apostrophes, colons, commas, question marks and percentage signs.
    Also, consider the length of a VARCHAR2 that you would have to use - how big would it need to be to cover all possibilities? You may say 20 now but tomorrow you get data with 21 characters in it - do you want to update the table plus all related tables for that?
    There are further issues with parent, child, grand-child etc relationships where the keys would have to be passed down in full through the relationships. Depending on how many levels you may have, a fair number of the fields on the bottom-most table would be there just for the keys.
    It has been a standard industry practice for many years now to "normalise databases" to avoid lots of issues with keys and "repeating data". Apart from very simple lookup tables, I have stuck with those guidelines for years now without any problems at all.
    Andy

  • Implementing surrogate keys in dimensions

    hello,
    First thing, I'm new to ODI! I am using Oracle data integrator 10.1.3.
    I have a dimension table 'Dim_Contracts' as target table. The structure is as follows:
    PK_Dim_Contract Primary key (surrogate key - to be populated from an Oracle database sequence in the target)
    Contract_ID (normal field in target - no constraints in target- to be populated from source - originally a primary key in source)
    + other dimension attributes.
    from what i have googled out and read in the forum, i cannot define 'PK_Dim_Contract' as the primary key of my dimension (target) table, to be able to update it from the oracle sequence defined - rather the 'contract_ID', which is the natural key should be the primary key. Is that correct? If yes, isn't it against dimension modelling principle?
    More to the point, my question is: How do I populate a sequence in my primary key field in the target table?
    Thanks for your help.
    Regards,
    Anju

    Hello Anju,
    Welcome in the ODI community ;).
    What I suggest you is to set the UNIQUE KEY on Contract_ID in your target. This way you will be able to use flow control and do Incremental Update Loading.
    PK_Dim_Contract (surrogate key) can be your primary key in the dabatase.
    To populate PK_Dim_Contract from an Oracle Sequence, create it first in your Oracle DB. Add a new sequence to your project (left pane), choose Natural Sequence, choose your schema and enter the name of your Oracle Sequence.
    In your interface, define the mapping of PK_Dim_Contract as
    :<ODI_SEQUENCE_NAME>_NEXTVALand execute this mapping on the target.
    Note: :<ODI_SEQUENCE_NAME>_NEXTVAL works only for SQL Statements. If you want to use the sequence somewhere else, use the following syntax :
    #<ODI_SEQUENCE_NAME>_NEXTVALHope it helps,
    Jerome

Maybe you are looking for

  • I'm being asked for my password when I shouldn't be in Net Prefs

    Hello, I don't understand why System Prefs asks me for my password to relock after I already entered it seconds earlier to unlock. Network prefs is where this happens, and it occurs about half the time. I'm hesitant to blindly enter my password whene

  • Scroll speed in Cover Flow???

    I love the cover flow view in finder and iTunes but I have a the new magic mouse and the scroll speed is just too fast... I have a hard time landing on the object I want, I just go back and forth back and forth over it... Is there a way to adjust scr

  • Vendor/Customer Periodic Transfer from GTS - Idoc errors

    Hi Guys Need your help on this, seems like when i am trying to send the reduced message type for /SAPSLL/CREMAS_SLL and DEBMAS_SLL I see that its generating IDOCS but its not communicating - 1 master IDocs set up for message type /SAPSLL/CREMAS_SLL b

  • Why some of the tables are not set cacheable by default.

    Hi all. in the case management analytics in OBIEE. (Case Management Analytics Fusion Edition) Some of the tables for example (W_CASE_D, W_INCIDENT_D, W_LEAD_D) are not set Cacheable. That means, select table, right click, properties, Cacheable is NOT

  • Sun JSF 1.1 or MyFaces Custom Validator Messages.

    Hello i must use JSF 1.1 version for some old project. The problem is that NOW i must use localization and internationalization API to make it "good" in my own language - Bulgarian ( Cyrilic language) The problem is that input components for 1.1 does