Question on passing string values to Partition clause in a merge statement

Hello All,
I am using the below code to update specific sub-partition data using oracle merge statements.
I am getting the sub-partition name and passing this as a string to the sub-partition clause.
The Merge statement is failing stating that the specified sub-partition does not exist. But the sub-partition do exists for the table.
We are using Oracle 11gr2 database.
Below is the code which I am using to populate the data.
declare
ln_min_batchkey PLS_INTEGER;
ln_max_batchkey PLS_INTEGER;
lv_partition_name VARCHAR2 (32767);
lv_subpartition_name VARCHAR2 (32767);
begin
FOR m1 IN ( SELECT (year_val + 1) AS year_val, year_val AS orig_year_val
FROM ( SELECT DISTINCT
TO_CHAR (batch_create_dt, 'YYYY') year_val
FROM stores_comm_mob_sub_temp
ORDER BY 1)
ORDER BY year_val)
LOOP
lv_partition_name :=
scmsa_handset_mobility_data_build.fn_get_partition_name (
p_table_name => 'STORES_COMM_MOB_SUB_INFO',
p_search_string => m1.year_val);
FOR m2
IN (SELECT DISTINCT
'M' || TO_CHAR (batch_create_dt, 'MM') AS month_val
FROM stores_comm_mob_sub_temp
WHERE TO_CHAR (batch_create_dt, 'YYYY') = m1.orig_year_val)
LOOP
lv_subpartition_name :=
scmsa_handset_mobility_data_build.fn_get_subpartition_name (
p_table_name => 'STORES_COMM_MOB_SUB_INFO',
p_partition_name => lv_partition_name,
p_search_string => m2.month_val);
                    DBMS_OUTPUT.PUT_LINE('The lv_subpartition_name => '||lv_subpartition_name||' and lv_partition_name=> '||lv_partition_name);
IF lv_subpartition_name IS NULL
THEN
                         DBMS_OUTPUT.PUT_LINE('INSIDE IF => '||m2.month_val);
INSERT INTO STORES_COMM_MOB_SUB_INFO T1 (
t1.ntlogin,
t1.first_name,
t1.last_name,
t1.job_title,
t1.store_id,
t1.batch_create_dt)
SELECT t2.ntlogin,
t2.first_name,
t2.last_name,
t2.job_title,
t2.store_id,
t2.batch_create_dt
FROM stores_comm_mob_sub_temp t2
WHERE TO_CHAR (batch_create_dt, 'YYYY') = m1.orig_year_val
AND 'M' || TO_CHAR (batch_create_dt, 'MM') =
m2.month_val;
ELSIF lv_subpartition_name IS NOT NULL
THEN
                    DBMS_OUTPUT.PUT_LINE('INSIDE ELSIF => '||m2.month_val);
MERGE INTO (SELECT *
FROM stores_comm_mob_sub_info
SUBPARTITION (lv_subpartition_name)) T1
USING (SELECT *
FROM stores_comm_mob_sub_temp
WHERE TO_CHAR (batch_create_dt, 'YYYY') =
m1.orig_year_val
AND 'M' || TO_CHAR (batch_create_dt, 'MM') =
m2.month_val) T2
ON (T1.store_id = T2.store_id
AND T1.ntlogin = T2.ntlogin)
WHEN MATCHED
THEN
UPDATE SET
t1.postpaid_totalqty =
(NVL (t1.postpaid_totalqty, 0)
+ NVL (t2.postpaid_totalqty, 0)),
t1.sales_transaction_dt =
GREATEST (
NVL (t1.sales_transaction_dt,
t2.sales_transaction_dt),
NVL (t2.sales_transaction_dt,
t1.sales_transaction_dt)),
t1.batch_create_dt =
GREATEST (
NVL (t1.batch_create_dt, t2.batch_create_dt),
NVL (t2.batch_create_dt, t1.batch_create_dt))
WHEN NOT MATCHED
THEN
INSERT (t1.ntlogin,
t1.first_name,
t1.last_name,
t1.job_title,
t1.store_id,
t1.batch_create_dt)
VALUES (t2.ntlogin,
t2.first_name,
t2.last_name,
t2.job_title,
t2.store_id,
t2.batch_create_dt);
END IF;
END LOOP;
END LOOP;
COMMIT;
end;
Much appreciate your inputs here.
Thanks,
MK.

I've not used partitioning, but I do not see MERGE supporting a variable as a partition name in
MERGE INTO (SELECT *
FROM stores_comm_mob_sub_info
SUBPARTITION (lv_subpartition_name)) T1
USING ... I suspect it is looking for a partition called lv_subpartition_name.
I also don't see why you need that partition name - the ON clause should be able to identify the partition's criteria.

Similar Messages

  • Issue while using SUBPARTITION clause in the MERGE statement in PLSQL Code

    Hello All,
    I am using the below code to update specific sub-partition data using oracle merge statements.
    I am getting the sub-partition name and passing this as a string to the sub-partition clause.
    The Merge statement is failing stating that the specified sub-partition does not exist. But the sub-partition do exists for the table.
    We are using Oracle 11gr2 database.
    Below is the code which I am using to populate the data.
    declare
    ln_min_batchkey PLS_INTEGER;
    ln_max_batchkey PLS_INTEGER;
    lv_partition_name VARCHAR2 (32767);
    lv_subpartition_name VARCHAR2 (32767);
    begin
    FOR m1 IN ( SELECT (year_val + 1) AS year_val, year_val AS orig_year_val
    FROM ( SELECT DISTINCT
    TO_CHAR (batch_create_dt, 'YYYY') year_val
    FROM stores_comm_mob_sub_temp
    ORDER BY 1)
    ORDER BY year_val)
    LOOP
    lv_partition_name :=
    scmsa_handset_mobility_data_build.fn_get_partition_name (
    p_table_name => 'STORES_COMM_MOB_SUB_INFO',
    p_search_string => m1.year_val);
    FOR m2
    IN (SELECT DISTINCT
    'M' || TO_CHAR (batch_create_dt, 'MM') AS month_val
    FROM stores_comm_mob_sub_temp
    WHERE TO_CHAR (batch_create_dt, 'YYYY') = m1.orig_year_val)
    LOOP
    lv_subpartition_name :=
    scmsa_handset_mobility_data_build.fn_get_subpartition_name (
    p_table_name => 'STORES_COMM_MOB_SUB_INFO',
    p_partition_name => lv_partition_name,
    p_search_string => m2.month_val);
                        DBMS_OUTPUT.PUT_LINE('The lv_subpartition_name => '||lv_subpartition_name||' and lv_partition_name=> '||lv_partition_name);
    IF lv_subpartition_name IS NULL
    THEN
                             DBMS_OUTPUT.PUT_LINE('INSIDE IF => '||m2.month_val);
    INSERT INTO STORES_COMM_MOB_SUB_INFO T1 (
    t1.ntlogin,
    t1.first_name,
    t1.last_name,
    t1.job_title,
    t1.store_id,
    t1.batch_create_dt)
    SELECT t2.ntlogin,
    t2.first_name,
    t2.last_name,
    t2.job_title,
    t2.store_id,
    t2.batch_create_dt
    FROM stores_comm_mob_sub_temp t2
    WHERE TO_CHAR (batch_create_dt, 'YYYY') = m1.orig_year_val
    AND 'M' || TO_CHAR (batch_create_dt, 'MM') =
    m2.month_val;
    ELSIF lv_subpartition_name IS NOT NULL
    THEN
                        DBMS_OUTPUT.PUT_LINE('INSIDE ELSIF => '||m2.month_val);
    MERGE INTO (SELECT *
    FROM stores_comm_mob_sub_info
    SUBPARTITION (lv_subpartition_name)) T1 --> Issue Here
    USING (SELECT *
    FROM stores_comm_mob_sub_temp
    WHERE TO_CHAR (batch_create_dt, 'YYYY') =
    m1.orig_year_val
    AND 'M' || TO_CHAR (batch_create_dt, 'MM') =
    m2.month_val) T2
    ON (T1.store_id = T2.store_id
    AND T1.ntlogin = T2.ntlogin)
    WHEN MATCHED
    THEN
    UPDATE SET
    t1.postpaid_totalqty =
    (NVL (t1.postpaid_totalqty, 0)
    + NVL (t2.postpaid_totalqty, 0)),
    t1.sales_transaction_dt =
    GREATEST (
    NVL (t1.sales_transaction_dt,
    t2.sales_transaction_dt),
    NVL (t2.sales_transaction_dt,
    t1.sales_transaction_dt)),
    t1.batch_create_dt =
    GREATEST (
    NVL (t1.batch_create_dt, t2.batch_create_dt),
    NVL (t2.batch_create_dt, t1.batch_create_dt))
    WHEN NOT MATCHED
    THEN
    INSERT (t1.ntlogin,
    t1.first_name,
    t1.last_name,
    t1.job_title,
    t1.store_id,
    t1.batch_create_dt)
    VALUES (t2.ntlogin,
    t2.first_name,
    t2.last_name,
    t2.job_title,
    t2.store_id,
    t2.batch_create_dt);
    END IF;
    END LOOP;
    END LOOP;
    COMMIT;
    end;
    Much appreciate your inputs here.
    Thanks,
    MK.
    (SORRY TO POST THE SAME QUESTION TWICE).
    Edited by: Maddy on May 23, 2013 10:20 PM

    Duplicate question

  • Problem with prepared statement where cluase when passing string value.Help

    I am updating a table using the following code. I am using string parameter in where clause. if I use Long parameter in where clause with ps.setLong , this code is working. Is there any special way to pass string value? Am I doing anything wrong?
    ===================
    updateMPSQL.append("UPDATE MP_Table SET ");
         updateMPSQL.append("MPRqmt = ?,End_Dt = ? ");
              updateMPSQL.append("where POS = ? ");
              System.out.println(updateMPSQL.toString());
              con     = getConnection(false) ;
              ps      = con.prepareStatement(updateMPSQL.toString());
              ps.setLong(1,MPB.getMPRqmt());
              ps.setDate(2,MPB.getEnd_Dt());
              ps.setString(3,MPB.getPos());
    result = ps.execute();
              System.out.println("Result : " + result);
    ==========
    Please help me.
    Thanks in advance.
    Regards,
    Sekhar

    doesn't Pos look like a number rather than a string variable?
    if I use Long
    parameter in where clause with ps.setLong , this code
    is working.
    updateMPSQL.append("where POS = ? ");
    ps.setString(3,MPB.getPos());

  • PASS STRING IN TO WHERE CLAUSE

    Hi All,
    i'm facing a problem when i used
    SELECT * INTO TABLE ITAB FROM T000 WHERE T000~MANDT IN (810, 812, 800).
    then it's gives three values which is right according to requirement.
    but i hve to use a string n pass these values by string so i developed a string V_STRING N IT'S VALUE IS SAME AS 810, 812, 800.
    MEANS
    V_STRING = 810, 812, 800
    BUT WHEN I PASSED THIS STRING TO THIS SELECT THEN IT'S GIVE ONLY ONE VALUE FOR ONLY FIRST VALUE MEANS FOR ONLY 810.
    PLS SUGGEST ME WHY IT'S ONLY THROW ING RESULT ONLY FOR ONE VALUE.
    REGARDS,

    The only dynamic select is allowed by using an internal table of not more than 72 characters, so build the full string WHERE clause like:
    DATA: where_clause TYPE TABLE OF char72,
          clause LIKE LINE OF where_clause.
    PARAMETER p_mandt TYPE char50.
    CONCATENATE 'MANDT IN (' p_mandt ')' INTO clause.
    APPEND clause TO where_clause.
    and then
    SELECT * FROM t000  CLIENT SPECIFIED
      WHERE (where_clause).
    Remenber the limit of 72 char. So if only one field is of concern, you should better build a RANGE type internal table and use it in a IN logical expression of the WHERE clause. (Use SPLIT AT ',')
    DATA it_mandt TYPE TABLE OF char4 WITH HEADER LINE.
    DATA range_mandt TYPE RANGE OF t000-mandt WITH HEADER LINE.
    SPLIT p_mandt AT ',' INTO TABLE it_mandt.
    CLEAR range_mandt.
    range_mandt-sign = 'I'.
    range_mandt-option = 'EQ'.
    LOOP AT it_mandt.
      CHECK NOT it_mandt IS INITIAL.
      CONDENSE it_mandt.
      range_mandt-low = it_mandt.
      APPEND range_mandt.
    ENDLOOP.
    and then
    SELECT * FROM t000  CLIENT SPECIFIED
      WHERE mandt IN range_mandt.
    Regards

  • Passing String values in the Function module

    Hi
    i am using a coustom made RFC, here i am usnig input parameter 'jobnature' of string type of length 720. the values is getting from the portal,
    i send a string of length of 720 charater from portal, but inside the RFC only 132 charaters are getting .why it happeded so, what is the solution .
    regards
    Renjith

    Hi renjith,
    1. don't give any length in the FM definition.
    2. just like this.
    STR     TYPE     STRING
    (Tick the checkbox for 'Pass Value')
    (Bcos its RFC Enabled)
    regards,
    amit m.

  • Issue with Submit and Return in passing string/values of longer length.

    Hi,
    I have a FM which has to submit a report as a job.
    I am required to send a string( length could be close to 1024 characters or more than that) to the report as the parameter.
    I am using Submit with Return.
    1.When I pass my string as parameters, in the report it gets truncated at 60 chars.( though i have defined the parameter of type char1024)I lose the data.
    2.When I split my string(aflter logical splitting the lenght is still equal to about 200 chars) and then pass as select options it gets truncated at 45 chars in the report ( though i have defined the parameter of type char1024)and i lose my data.
    3.I cannot use Export/Import as I found that it does not work with jobs.
    Please let me know how can i sumbit the report as a job while passing it a string of length 1024 characters.
    Regards,
    Sulakshana
    Edited by: Sulakshana Shinde on May 21, 2009 2:44 PM

    Option 3 should work, unless you are not using the EXPORT/IMPORT correctly.  I believe that you are going across work processes, which means you may need to use the shared buffer or shared memory when using the export/import statements.  
    Something like this.
    Data: lv_value type string.
    lv_value = 'SomeValue'.
    EXPORT lv_value = lv_value
           TO SHARED BUFFER INDX(ST) ID 'SomeUnigueKey'.
    See this.
    http://help.sap.com/abapdocu/en/ABAPEXPORT_DATA_CLUSTER_MEDIUM.htm
    Regards,
    Rich Heilman

  • How to pass string value to call function in BIIP FOX?

    Dear all,
       In BIIP fox , we can call function module.
       I got a simple test FM like:
    FUNCTION ZTESTBPSFM2.
    ""Local Interface:
    *"  IMPORTING
    *"     REFERENCE(I_X) TYPE  STRING
    *"     REFERENCE(I_H) TYPE  BSP_STRING
    *"  EXPORTING
    *"     REFERENCE(I_Y) TYPE  F
    ENDFUNCTION.
    My FOX is like,
    DATA YM TYPE 0CALMONTH.
    DATA I_N TYPE F.
    DATA J TYPE STRING.
    J = 'KKKK'.
    FOREACH YM.
    CALL FUNCTION ZTESTBPSFM2
    EXPORTING
    I_X = J
    IMPORTING
    I_Y = I_N.
    {ZREV , YM} = I_N.
    ENDFOR.
    When I run the function , I got a error .
    "Types of parameter I_X (S) and variable J(C) are inconsistent "
    Does anyone know which string data type I should use in function module?
    Best Regards,
    Jeff

    Hi Jeff
    this is a bug. Please open a customer message so SAP support can correct the issue.
    Regards,
    Marc
    SAP NetWeaver RIG

  • Please Help: query matching string value in WHERE clause

    Hi Everyone,
    I am trying to query customers that has matching first and last name but, I am getting result of every customer that has first and last name. Here is what my query looks like:
    SELECT * FROM  CUSTOMERS WHERE
    CUSTOMER_FNAME IN
    'JOHN', 'MIKE'
    AND CUSTOMER_LNAME IN
    'DOE', 'MILLER'
    ); I am trying to query customer name that is JOHN DOE and MIKE MILLER but, i get result of all names that has the first/last names not exact match. Is there way i can do that get exact match?
    Thanks,
    SM

    Frank Kulash wrote:
    Hi,
    chris227 wrote:
    SMCR wrote:
    Thanks everyone for your help!
    There are two correct answers, I am using following:I just see one, it's Franks.If fname never contains a '~' (or if lname never contains a '~") then
    {code}
    where fname||'~'||lname in ('JOHN~DOE', 'MIKE~MILLER');
    {code}
    will work.Yes, I realized that. For the purpose i am using i will not have any issue with '~'
    I did however changed it up a little, here is how it looks like:
    {code}
    SELECT CUSTOMER_ID, CUSTOMER_FNAME, CUSTOMER_LNAME, DATE_OF_BIRTH
    FROM CUSTOMERS
    WHERE (CUSTOMER_FNAME||'~'||CUSTOMER_LNAME, DATE_OF_BIRTH) IN
    (('JOHN~DOE'), (TO_DATE('20130101', 'YYYYMMDD'))),
    (('MIKE~MILLER'), (TO_DATE('20130101', 'YYYYMMDD')))
    {code}

  • How to pass a value and call SE38 program using SUBMIT statement

    Hello Friends
    I am trying to write a batch program in SE38, that calls other SE38 Programs.
    I don't want to use Parameter command to see the value on screen.
    All I want is to send a range of date (ToDate & FromDate) and generate different reports satisfying this date range condition.
    Can some one please help me with this. I would really appreciate it.
    I have tried the command SUBMIT with options of filling the input fields of the subsequent programs but I don't want to do this.
    I want all the sub programs to be called one after another and the reports generated using the date varialbles I send from the main program.
    I don't want to use se37 functions because of the client's request.
    Any help will be highly appreciated.
    Tks
    Ram

    Yes I am using SUBMIT command but I was not using the right options with the SUBMIT command and once I used the right options, it worked.
    Tks
    Ram

  • Tree List Value - Passing String

    apex4
    database 10g EE
    I have this code which will pass a value to a textfiled but only numbers. How about passing string values in a textfield? Any idea?
    select case when connect_by_isleaf = 1 then 0
                when level = 1             then 1
                else                           -1
           end as status,
           level,
           "ENAME" as title,
           null as icon,
           "EMPNO" as value,
           "ENAME" as tooltip,
           'javascript:$s("P13_EMPNO",'||EMPNO||');' as link
    from "#OWNER#"."EMP"
    start with "MGR" is null
    connect by prior "EMPNO" = "MGR"
    order siblings by "ENAME"

    Hi Jose,
    I believe Patrick already responded to this question on another thread: Tree List Value , where he has stated:
    just use
    'javascript:$s("P13_ENAME","'||ENAME||'");' as link
    instead.
    Regards,
    Hilary

  • Passing JSP value into an SQL Query

    Hi,
    I am developing a site for a cruise ship company as part of a project. My problem is as follows . . .
    I have a page called cruiseReservation.jsp which passes the value of the selected cabin to the cruiseDetails.jsp page:
    href="CruiseDetails.jsp?cabin_id=cabinE105 " so . .
    cabinE105 was selected.
    my database table for the cabin is as follows:
    create table cabin (
    cruise_id number primary key,
    cabinE105 number,
    cabinD113 number,
    cabinC131 number,
    cabinB127 number,
    cabinA101 number,
    FOREIGN KEY(cruise_id)
    REFERENCES cruisedetails(cruise_id)
    In the cruise details page im running the following code to update the cabin tables cabinE105 value to 0:
    String cabin = request.getParameter("cabin_id");
    String setCabin = "update cabin set '"+cabin+'" = 0 where cruise_id = 1";
    What im trying to do is pass the value of the cabin into the update statement so it updates cabinE105 = 0 where cruise_id = 1.
    How do I dfo this as the above method is not working ??
    I would like any help on this PLEASE !!! THANKS !

    String cabinID = request.getParameter("cabin_id");
    PreparedStatement ps=connection.prepareStatement("update cabin set "+cabinID+"=? where cruise_id=?");
    ps.setInt(1,0);
    ps.setInt(2,0);
    ps.executeUpdate();
    .Regards
    -John-

  • Can't we use function to derive value for NEXT clause in MV ?

    Hi Friends,
    I have a requirement like below
    I need to derive the schedule (Value for NEXT clause in the create MV command) for a MV to run it
    e.g., Value from a date column : 03-JUL-2012 10:00 AM, VALUE for NEXT clause in CREATE MV statement should be 03-JUL-2012 04:45 AM (It is -5.45 hrs from the above date column value )
    So I wrote a function (GET_DATE) to derive schedule for NEXT clause and tried to call it from NEXT caluse, but it is giving error message as mentioned below
    ORA-04044: procedure, function, package, or type is not allowed here
    CREATE MATERIALIZED VIEW child_mv
    PARALLEL 16
    INITRANS 16
    STORAGE (
    FREELISTS 16
    FREELIST GROUPS 4
    BUILD IMMEDIATE
    REFRESH COMPLETE
    NEXT GET_DATE('PARENT_MV')
    AS
    SELECT * from xxmdme_party_stage where rownum<101;
    Could you please help to give some light on how this can be done ?

    942661 wrote:
    Hi Friends,
    I have a requirement like below
    I need to derive the schedule (Value for NEXT clause in the create MV command) for a MV to run it
    e.g., Value from a date column : 03-JUL-2012 10:00 AM, VALUE for NEXT clause in CREATE MV statement should be 03-JUL-2012 04:45 AM (It is -5.45 hrs from the above date column value )
    So I wrote a function (GET_DATE) to derive schedule for NEXT clause and tried to call it from NEXT caluse, but it is giving error message as mentioned below
    ORA-04044: procedure, function, package, or type is not allowed here
    CREATE MATERIALIZED VIEW child_mv
    PARALLEL 16
    INITRANS 16
    STORAGE (
    FREELISTS 16
    FREELIST GROUPS 4
    BUILD IMMEDIATE
    REFRESH COMPLETE
    NEXT GET_DATE('PARENT_MV')
    AS
    SELECT * from xxmdme_party_stage where rownum<101;
    Could you please help to give some light on how this can be done ?you must (ab)use EXECUTE IMMEDIATE

  • Question about Merge Statement

    Is it possible to use a CASE statement inside the update clause of a merge statement? Also what about a function?
    I have a string (In Source) that needs to be split into multiple columns (In Target) depending on values in other columns (In Source).
    I am on 11iR1

    Hi Chris,
    You can take a look at the below examples :
    SQL>create table t_test
    col1,col2,col3
    ) as
    select 1,2,3 from dual union all
    select 2,3,4 from dual union all
    select 3,4,2 from dual union all
    select 9,10,12 from dual union all
    select 11,23,43 from dual
    create table succeeded.
    SQL>select * from t_test;
    COL1                   COL2                   COL3                  
    1                      2                      3                     
    2                      3                      4                     
    3                      4                      2                     
    9                      10                     12                    
    11                     23                     43    
    SQL>merge INTO t_test t_t USING
      SELECT
        1 AS col1
      FROM
        dual
    ) d_d
    ON
    (d_d.col1 = t_t.col1)
    WHEN matched THEN
      UPDATE set
        col2 = (
          CASE
            WHEN d_d.col1 = 1
            THEN 123
            ELSE -1
          END );
    1 rows merged
    SQL>select * from t_test;
    COL1                   COL2                   COL3                  
    1                      123                    3                     
    2                      3                      4                     
    3                      4                      2                     
    9                      10                     12                    
    11                     23                     43                    

  • How to pass multiple query string values using the same parameter in Query String (URL) Filter Web Part

    Hi,
    I want to pass multiple query string values using the same parameter in Query String (URL) Filter Web Part like mentioned below:
    http://server/pages/Default.aspx?Title=Arup&Title=Ratan
    But it always return those items whose "Title" value is "Arup". It is not returned any items whose "Title" is "Ratan".
    I have followed the
    http://office.microsoft.com/en-us/sharepointserver/HA102509991033.aspx#1
    Please suggest me.
    Thanks | Arup
    THanks! Arup R(MCTS)
    SucCeSS DoEs NOT MatTer.

    Hi DH, sorry for not being clear.
    It works when I create the connection from that web part that you want to be connected with the Query String Filter Web part. So let's say you created a web part page. Then you could connect a parameterized Excel Workbook to an Excel Web Access Web Part
    (or a Performance Point Dashboard etc.) and you insert it into your page and add
    a Query String Filter Web Part . Then you can connect them by editing the Query String Filter Web Part but also by editing the Excel Web Access Web Part. And only when I created from the latter it worked
    with multiple values for one parameter. If you have any more questions let me know. See you, Ingo

  • Passing String Which Has Single Quote Row/Value to a Function Returns Double Quoate

    Hi, I'm getting weird thing in resultset. When I pass String which has single quote value in it to a split function , it returns rows with double quote. 
    For example  following string:
    'N gage, Wash 'n Curl,Murray's, Don't-B-Bald
    Returns:
    ''N gage, Wash ''n Curl,Murray''s, Don''t-B-Bald
    Here is the split function:
    CREATE Function [dbo].[fnSplit] (
    @List varchar(8000), 
    @Delimiter char(1)
    Returns @Temp1 Table (
    ItemId int Identity(1, 1) NOT NULL PRIMARY KEY , 
    Item varchar(8000) NULL 
    As 
    Begin 
    Declare @item varchar(4000), 
    @iPos int 
    Set @Delimiter = ISNULL(@Delimiter, ';' ) 
    Set @List = RTrim(LTrim(@List)) 
    -- check for final delimiter 
    If Right( @List, 1 ) <> @Delimiter -- append final delimiter 
    Select @List = @List + @Delimiter -- get position of first element 
    Select @iPos = Charindex( @Delimiter, @List, 1 ) 
    While @iPos > 0 
    Begin 
    -- get item 
    Select @item = LTrim( RTrim( Substring( @List, 1, @iPos -1 ) ) ) 
    If @@ERROR <> 0 Break -- remove item form list 
    Select @List = Substring( @List, @iPos + 1, Len(@List) - @iPos + 1 ) 
    If @@ERROR <> 0 Break -- insert item 
    Insert @Temp1 Values( @item ) If @@ERROR <> 0 Break 
    -- get position pf next item 
    Select @iPos = Charindex( @Delimiter, @List, 1 ) 
    If @@ERROR <> 0 Break 
    End 
    Return 
    End
    FYI: I'm getting @List value from a table and passing it as a string to split function.
    Any help would be appreciated!
    ZK

    fixed the issue by using Replace function like
    Replace(value,'''''','''')
    Big Thanks Patrick Hurst!!!!! :)
    Though I came to another issue which I posted here:
    https://social.msdn.microsoft.com/Forums/sqlserver/en-US/a26469cc-f7f7-4fb1-ac1b-b3e9769c6f3c/split-function-unable-to-parse-string-correctly?forum=transactsql
    ZK

Maybe you are looking for

  • How to set a proxy in the KNetworkManager?

    Hey! In the university, I usually to connect in a wi-fi network that has a proxy to acess the internet. Is there a way to change the system proxy automatically, so I connect? Thanks! Last edited by Uchiha (2011-09-09 11:21:11)

  • Read line and delete line

    Hi Experts , I am doing a report on material history where I need to find out open orders....if suppose a matnr does'nt have Po then also I need to display as it will have open PR. Now I want to delete the line where ebeln eq space but I can't put th

  • Routing the SAP RFC

    Dear Folks, While doing STMS configuration, the SAP Server automatically configure the RFC for the server which are included in the Transport Route. Same as while adding the satellite system to SOLMAN , the SOLMAN Server automatically added the RFC a

  • What does the "(4)" mean?

    Hello all! I was simply wondering what the (4) means after my device name on icloud and all: "Macbook Air (4)" Thanks

  • I'd like to push out a terminal command in os x that would update firefox

    I manage over 500 macs at my job and I'd like to see if there is a unix command I can run that would force firefox to check for updates and install them if they're available.