Uploading file with comma separator

Hi firends,
I have a text file in the format below.
"abc","dedffrt","asd"
The value of field is enclosed in double quotes and each values are separated by comma.
I have tried with the function modules available for upload but of no use.
Im aware of the methods uploading and splitting ...
But i want to know is there any other function modules available to upload the file of this type.
Keshav

Hi KSD,
Try this way.
REPORT ztest_notepad.
DATA: BEGIN OF it_t001 OCCURS 0,
        bukrs TYPE t001-bukrs,
        butxt TYPE t001-butxt,
      END OF it_t001.
DATA: BEGIN OF it_file OCCURS 0,
        data TYPE char255,
      END OF it_file.
START-OF-SELECTION.
  CALL FUNCTION 'GUI_UPLOAD'
    EXPORTING
      filename = 'C:\hor_file.txt'
      filetype = 'ASC'
    TABLES
      data_tab = it_file.
  REPLACE ALL OCCURRENCES OF '"' IN TABLE it_file WITH space.
  LOOP AT it_file.
    SPLIT it_file-data AT ',' INTO it_t001-bukrs it_t001-butxt.
    APPEND it_t001.
    CLEAR it_t001.
  ENDLOOP.
  LOOP AT it_t001.
    WRITE:/ it_t001-bukrs, it_t001-butxt.
  ENDLOOP.
<li>Text file
"CGH","CGH Hospital"
"KKH","KKH hospital"
"SGH","SGH Hospital"
Thanks
Venkat.O

Similar Messages

  • Download internal table as text file with comma separation

    hi all
    I wanted text file separated by comma. I used the CSV function module, but the result is separeted by semicolon,instead i need comma.
    Kindly suggest some solution.
    Thanks
    Subha

    use this fm to convert to csv file
    CALL FUNCTION 'SAP_CONVERT_TO_TEX_FORMAT'
        EXPORTING
          I_FIELD_SEPERATOR    = ','
        TABLES
          I_TAB_SAP_DATA       = ITAB_FINAL
        CHANGING
          I_TAB_CONVERTED_DATA = ITAB_OUTPUT
        EXCEPTIONS
          CONVERSION_FAILED    = 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.
    itab_output is of type ITAB_OUTPUT TYPE TRUXS_T_TEXT_DATA,
    and then download using gui_download
    CALL FUNCTION 'GUI_DOWNLOAD'
          EXPORTING
            FILENAME                = W_FILENAME
            FILETYPE                = 'ASC'
          TABLES
            DATA_TAB                = ITAB_OUTPUT
          EXCEPTIONS
            FILE_WRITE_ERROR        = 1
            NO_BATCH                = 2
            GUI_REFUSE_FILETRANSFER = 3
            INVALID_TYPE            = 4
            NO_AUTHORITY            = 5
            UNKNOWN_ERROR           = 6
            HEADER_NOT_ALLOWED      = 7
            SEPARATOR_NOT_ALLOWED   = 8
            FILESIZE_NOT_ALLOWED    = 9
            HEADER_TOO_LONG         = 10
            DP_ERROR_CREATE         = 11
            DP_ERROR_SEND           = 12
            DP_ERROR_WRITE          = 13
            UNKNOWN_DP_ERROR        = 14
            ACCESS_DENIED           = 15
            DP_OUT_OF_MEMORY        = 16
            DISK_FULL               = 17
            DP_TIMEOUT              = 18
            FILE_NOT_FOUND          = 19
            DATAPROVIDER_EXCEPTION  = 20
            CONTROL_FLUSH_ERROR     = 21
            OTHERS                  = 22.

  • How to import data from CSV file with columns separated by semicolon?

    I migrate database from MS SQL 2008 to ORACLE 11g
    I export data to CSV file from MS SQL
    then I try to import it to Oracle
    several tables goes fine using Import data option in the SQL Developer
    Standard CSV files with data separated by comma were imported.
    chars, date (with format string), and integer data are imported via import wizard without problems
    the problems were when I try to import table with noninteger numbers with modal part separated by comma not by dot
    comma is the standard separator for columns in CSV file
    so I must change the standard separator to semicolon
    then the import wizard have problem to correct recognize the columns data because it use only standard CSV comma separator :-/
    In SQL Developer 1.5.3 Tools -> Preferences -> Migration -> Data Move Options
    I change "End of Column Delimiter" to ; but it doens't work
    Is this possible to change the standard column separator for import data wizzard in SQL Developer 1.5.3?
    Or maybe someone know how to import data in SQL Developer 1.5.3 from CSV when CSV colunn separator is set to semicolon?

    A new preference has been added to customize the import delimiter in main code line. This should be available as part of future release.

  • Open Hub File ignores comma separator

    Hi friends,
    I've got a problem while extracting a csv file with an open hub service.
    In the system my user (tab default) has US decimal format, and I can see the values in the infocubes correctly.
    But when I extract this values thru open hub service to a csv file, the comma separator and decimal point disappear.
    I thought it was a problem of the configuration of my pc, so I modified the regional options selecting US format.
    But, even doing this, when I open the csv file with excel the comma separator and decimal point doesn't exist.
    I know there exist a transaction called something like "RSRVT" or similar that can definy the thousand separator, but I don't remember the exact name.
    The field that I'm interested in the open hub file is defined as NUMC, length 17 and 3 decimal. I've tried to define with DEC format or CURR with similar result (totally failed).
    Can anybody help me!... this is very urgent.
    Thanks a lot.
    Francis.

    Hi
    check out this link too...
    http://help.sap.com/saphelp_nw2004s/helpdata/en/8e/dbe92341c84242be2c7d3917f1c197/frameset.htm
    Re: Flat file data load
    swetha

  • How can i get all these values in single row with comma separated?

    I have a table "abxx" with column "absg" Number(3)
    which is having following rows
    absg
    1
    3
    56
    232
    43
    436
    23
    677
    545
    367
    xxxxxx No of rows
    How can i get all these values in single row with comma separated?
    Like
    output_absg
    1,3,56,232,43,436,23,677,545,367,..,..,...............
    Can you send the query Plz!

    These all will do the same
    create or replace type string_agg_type as object
    2 (
    3 total varchar2(4000),
    4
    5 static function
    6 ODCIAggregateInitialize(sctx IN OUT string_agg_type )
    7 return number,
    8
    9 member function
    10 ODCIAggregateIterate(self IN OUT string_agg_type ,
    11 value IN varchar2 )
    12 return number,
    13
    14 member function
    15 ODCIAggregateTerminate(self IN string_agg_type,
    16 returnValue OUT varchar2,
    17 flags IN number)
    18 return number,
    19
    20 member function
    21 ODCIAggregateMerge(self IN OUT string_agg_type,
    22 ctx2 IN string_agg_type)
    23 return number
    24 );
    25 /
    create or replace type body string_agg_type
    2 is
    3
    4 static function ODCIAggregateInitialize(sctx IN OUT string_agg_type)
    5 return number
    6 is
    7 begin
    8 sctx := string_agg_type( null );
    9 return ODCIConst.Success;
    10 end;
    11
    12 member function ODCIAggregateIterate(self IN OUT string_agg_type,
    13 value IN varchar2 )
    14 return number
    15 is
    16 begin
    17 self.total := self.total || ',' || value;
    18 return ODCIConst.Success;
    19 end;
    20
    21 member function ODCIAggregateTerminate(self IN string_agg_type,
    22 returnValue OUT varchar2,
    23 flags IN number)
    24 return number
    25 is
    26 begin
    27 returnValue := ltrim(self.total,',');
    28 return ODCIConst.Success;
    29 end;
    30
    31 member function ODCIAggregateMerge(self IN OUT string_agg_type,
    32 ctx2 IN string_agg_type)
    33 return number
    34 is
    35 begin
    36 self.total := self.total || ctx2.total;
    37 return ODCIConst.Success;
    38 end;
    39
    40
    41 end;
    42 /
    Type body created.
    [email protected]>
    [email protected]> CREATE or replace
    2 FUNCTION stragg(input varchar2 )
    3 RETURN varchar2
    4 PARALLEL_ENABLE AGGREGATE USING string_agg_type;
    5 /
    CREATE OR REPLACE FUNCTION get_employees (p_deptno in emp.deptno%TYPE)
    RETURN VARCHAR2
    IS
    l_text VARCHAR2(32767) := NULL;
    BEGIN
    FOR cur_rec IN (SELECT ename FROM emp WHERE deptno = p_deptno) LOOP
    l_text := l_text || ',' || cur_rec.ename;
    END LOOP;
    RETURN LTRIM(l_text, ',');
    END;
    SHOW ERRORS
    The function can then be incorporated into a query as follows.
    COLUMN employees FORMAT A50
    SELECT deptno,
    get_employees(deptno) AS employees
    FROM emp
    GROUP by deptno;
    ###########################################3
    SELECT SUBSTR(STR,2) FROM
    (SELECT SYS_CONNECT_BY_PATH(n,',')
    STR ,LENGTH(SYS_CONNECT_BY_PATH(n,',')) LN
    FROM
    SELECT N,rownum rn from t )
    CONNECT BY rn = PRIOR RN+1
    ORDER BY LN desc )
    WHERE ROWNUM=1
    declare
    str varchar2(32767);
    begin
    for i in (select sal from emp) loop
    str:= str || i.sal ||',' ;
    end loop;
    dbms_output.put_line(str);
    end;
    COLUMN employees FORMAT A50
    SELECT e.deptno,
    get_employees(e.deptno) AS employees
    FROM (SELECT DISTINCT deptno
    FROM emp) e;
    DEPTNO EMPLOYEES
    10 CLARK,KING,MILLER
    20 SMITH,JONES,SCOTT,ADAMS,FORD
    30 ALLEN,WARD,MARTIN,BLAKE,TURNER,JAMES
    CREATE OR REPLACE FUNCTION concatenate_list (p_cursor IN SYS_REFCURSOR)
    RETURN VARCHAR2
    IS
    l_return VARCHAR2(32767);
    l_temp VARCHAR2(32767);
    BEGIN
    LOOP
    FETCH p_cursor
    INTO l_temp;
    EXIT WHEN p_cursor%NOTFOUND;
    l_return := l_return || ',' || l_temp;
    END LOOP;
    RETURN LTRIM(l_return, ',');
    END;
    COLUMN employees FORMAT A50
    SELECT e1.deptno,
    concatenate_list(CURSOR(SELECT e2.ename FROM emp e2 WHERE e2.deptno = e1.deptno)) employees
    FROM emp e1
    GROUP BY e1.deptno;
    DEPTNO EMPLOYEES
    10 CLARK,KING,MILLER
    20 SMITH,JONES,SCOTT,ADAMS,FORD
    30 ALLEN,WARD,MARTIN,BLAKE,TURNER,JAMES
    CREATE OR REPLACE TYPE t_string_agg AS OBJECT
    g_string VARCHAR2(32767),
    STATIC FUNCTION ODCIAggregateInitialize(sctx IN OUT t_string_agg)
    RETURN NUMBER,
    MEMBER FUNCTION ODCIAggregateIterate(self IN OUT t_string_agg,
    value IN VARCHAR2 )
    RETURN NUMBER,
    MEMBER FUNCTION ODCIAggregateTerminate(self IN t_string_agg,
    returnValue OUT VARCHAR2,
    flags IN NUMBER)
    RETURN NUMBER,
    MEMBER FUNCTION ODCIAggregateMerge(self IN OUT t_string_agg,
    ctx2 IN t_string_agg)
    RETURN NUMBER
    SHOW ERRORS
    CREATE OR REPLACE TYPE BODY t_string_agg IS
    STATIC FUNCTION ODCIAggregateInitialize(sctx IN OUT t_string_agg)
    RETURN NUMBER IS
    BEGIN
    sctx := t_string_agg(NULL);
    RETURN ODCIConst.Success;
    END;
    MEMBER FUNCTION ODCIAggregateIterate(self IN OUT t_string_agg,
    value IN VARCHAR2 )
    RETURN NUMBER IS
    BEGIN
    SELF.g_string := self.g_string || ',' || value;
    RETURN ODCIConst.Success;
    END;
    MEMBER FUNCTION ODCIAggregateTerminate(self IN t_string_agg,
    returnValue OUT VARCHAR2,
    flags IN NUMBER)
    RETURN NUMBER IS
    BEGIN
    returnValue := RTRIM(LTRIM(SELF.g_string, ','), ',');
    RETURN ODCIConst.Success;
    END;
    MEMBER FUNCTION ODCIAggregateMerge(self IN OUT t_string_agg,
    ctx2 IN t_string_agg)
    RETURN NUMBER IS
    BEGIN
    SELF.g_string := SELF.g_string || ',' || ctx2.g_string;
    RETURN ODCIConst.Success;
    END;
    END;
    SHOW ERRORS
    CREATE OR REPLACE FUNCTION string_agg (p_input VARCHAR2)
    RETURN VARCHAR2
    PARALLEL_ENABLE AGGREGATE USING t_string_agg;
    /

  • Impossible Upload files with Filezilla FTP Client after upgrade win8 to win8.1

    Hi
    Things were working fine with win 8 but, after Upgrade to win 8.1 is not possible upload files with Filezilla  FTP Client.
    is there anyone facing same problem?
    thanks in advance for any answer to help me solve this issue 
    Regards 
    TC

    Hi,
    Please Change your transfer settings in site manager from either default or passive to active it to see what's going on.
    Also, check IE compatibility mode.
    In addition, I suggest you install all latest updates for Windows since these updates will improve and fix some known issues.
    Kate Li
    TechNet Community Support

  • Logic to upload file with dynamic columns

    hi
    in my requirement i hav given to add logic to upload file with dynamic columns so that this upload program can be reused.
    this way the program is flexible, irrespective of the number of columns in the file.
    can any one explain this?
    and let me know what actually i hav to do.

    Check the program and the dynamic column is in the col_pos internal table and in the routines get_structure onwards.
    https://www.sdn.sap.com/irj/sdn/wiki?path=/display/scm/dynamic%2bstructures%2band%2bcomponents
    cheers
    Aveek

  • Adding a parameter with comma separated having different values

    i want to add a parameter with comma separated having different values of a column. e.g i have column having values from 10000 to 99999. i want to create report for the selected values of 11111,12111,131111 etc. This selection can be one or more values as desired. Second problem is restricting the records as per parameter.

    Reports doesn't allow multi-selection of a parameter in its parameter form. You need to use Oracle*Forms or an HTML Form to front end more advanced parameter form options.
    However, you could have multiple parameters and combine their selections into a single parameter in the after parameter form trigger. This would at least allow you to give the user the option for selecting up to 'n' parameters. The single parameter would have to be of type "character" and you probably want to add appropriate quotes around the values in the after parameter form trigger.
    Second problem is restricting the records as per parameter. Once you've got the comma seperated values into a single parameter (say p_myValues with a default value of '') then you can just use a lexical parameter to restrict the values as in:
    select * from emp
    where to_char(empno) in (&p_myValues)

  • Unable to Load CSV file with comma inside the column(Sql Server 2008)

    Hi,
    I am not able load an CSV file with Comma inside a column. 
    Here is sample File:(First row contain the column names)
    _id,qp,c
    "1","[ ""0"", ""0"", ""0"" ]","helloworld"
    "1","[ ""0"", ""0"", ""0"" ]","helloworld"
    When i specify the Text Qualifier as "(Double quotes) it work in SQL Server 2012, where as fail in the SQL Server 2008, complaining with error:
    TITLE: Microsoft Visual Studio
    The preview sample contains embedded text qualifiers ("). The flat file parser does not support embedding text qualifiers in data. Parsing columns that contain data with text qualifiers will fail at run time.
    BUTTONS:
    OK
    I need to do this in sql server 2008 R2 with Service pack 2, my build version is 10.50.1600.1.
    Can someone let me know it is possible in do the same way it is handle in SQL Server 2012?
    Or
    It got resolved in any successive Cumulative update after 10.50.1600.1?
    Regards Harsh

    Hello,
    If you have CSV with double quotes inside double quotes and with SSIS 2008, I suggest:
    in your data flow you use a script transformation component as Source, then define the ouput columns id signed int, Gp unicode string and C unicode string. e.g. Ouput 0 output colmuns
    Id - four-byte signed
    gp - unicode string
    cc - unicode string
    Do not use a flat file connection, but use a user variable in which you store the name of the flat file (this could be inside a for each file loop).
    The user variable is supplied as a a readonly variable argument to the script component in your dataflow.
    In the script component inMain.CreateNewOutputRows use a System.IO.Streamreader with the user variable name to read the file and use the outputbuffer addrow method to add each line to the output of the script component.
    Between the ReadLine instraction and the addrow instruction you have to add your code to extract the 3 column values.
    public override void CreateNewOutputRows()
    Add rows by calling the AddRow method on the member variable named "<Output Name>Buffer".
    For example, call MyOutputBuffer.AddRow() if your output was named "MyOutput".
    string line;
    System.IO.StreamReader file = new System.IO.StreamReader( Variables.CsvFilename);
    while ((line = file.ReadLine()) != null)
    System.Windows.Forms.MessageBox.Show(line);
    if (line.StartsWith("_id,qp,c") != true) //skip header line
    Output0Buffer.AddRow();
    string[] mydata = Yourlineconversionher(line);
    Output0Buffer.Id = Convert.ToInt32(mydata[0]);
    Output0Buffer.gp = mydata[1];
    Output0Buffer.cc = mydata[2];
    file.Close();
    Jan D'Hondt - SQL server BI development

  • Upload files with swedish characters NS 4.7

    Hi,
    I can upload files with swedish characters in the file name with IE 5, but not with Netscape 4.7. iFS presents an error message that the file doesn't exist or is empty.
    Is there a solution for this problem?
    /Elin
    null

    check out if you are using javascripts and whether IE supports it
    Roberto Nanamura <[email protected]> wrote:
    >
    Hi,
    I am having a problem uploading files with Internet Explorer, it works with
    Netscape Communicator. Has someone had the same problem?
    I am using WebLogic 5.1 service pack 5 with Netscape iPlanet 4.1 service pack 2
    in a Solaris 7.
    Best regards,
    Roberto N Nanamura
    Technical Consultant
    Summa Technologies

  • Currency with comma separator

    Hi all ,
    I have a currency filed TFULLVACWTG. I am summing all values like this
    TFULLVACWTG = VFWTG001 + VFWTG002 + VFWTG003 + VFWTG004 + VFWTG005 . iam getting output like  this 14092.00 i should get output like this 14,092.00
    I should write output with comma separator .is there any key word or f.m for this one?

    Hi Priya,
    You have two options.
    1) Changes in user master record ie change thousand separator as , and decimal separator as .(dot).
    You can do this with transaction SU3.
    2) If you dont want to change master record then try with this code.
    DATA VC_TFULLVACWTG(18).
    VC_TFULLVACWTG = TFULLVACWTG.
    TRANSLATE VC_TFULLVACWTG USING ',#'.
    TRANSLATE VC_TFULLVACWTG USING '.,'.
    TRANSLATE VC_TFULLVACWTG USING '#.'.
    WRITE VC_TFULLVACWTG.
    Thanks,
    Vinay

  • Upload files with international content

    I want to upload files with international content(many languages), from
    a single JSP. Any ideas?
    thanks,
    M.

    Hi Marco,
    I dont know transaction CV02N. But if this application uses standard function modules like GUI_UPLOAD it should work with ITS. A special configuration should not be required as long as the files have a size up to 5 MB. If they are larger it might be required to adjust the size of the request container MaxReqSize. Dont forget that Java has to be activated to let webgui access the filesystem.
    Regards,
    Klaus

  • One column having multiple values with comma separator.

    Hey Guys,
    In my db, one culmn having multiple values with comma separator. like column_name = 'value1,value2,value3'. Now I want to compare this column to another column and fetch in Cursor.
    and each value having corresponding email_id, By fetching cursor, I need to populate email_ids.
    Thanks in advance!!
    -Lakshman

    Please compare and fetch cursor and populate result with out extract data into temp table. Give me the query!You have not provided DDL for table so I don't know table or column name to write any SQL.
    You have not provided DML for test data to run SQL against.

  • How to associate an uploaded file with form data

    I have a "ticketing" app which stores a ticket no. as well as allows users to upload multiple files per ticket. The problem I am having is how to associate an uploaded file with a particular ticket no. As you can guess this becomes complicated when the same user can potentially update multiple tickets using the same file names. I am having difficulty trying to understand how to associate a ticket no with one or more uploaded files. I do have a custom table which I update with the attachments but I am unsure how to, or when to, update the ticket information on this custom table. I only want to retrieve attachments for a given ticket, not all attachments uploaded by a user.Does anyone have any ideas?

    Hi,
    My question is bit related to this topic.
    I am having a requirement to upload the CSV files so that they will store in a database table and later on wards when they search on that table it needs to pull the information and display on the form. I am a new bee to application express. Could some body tell me how to start this process with??. Just give me an overvoew/hints so that I will try to carry on my own.
    Cheers,
    Krishna.

  • Flat files data comma separated using SSIS.

    Hi,
    I have multiple flat files which come in comma separated columns. See example below :
    Customer Data
    CustID,FName,LName,Disease,Email,Phone
    12345,Xyz,Smit,Bronchitis, Asthma and fever,[email protected],80000000
    12346,Abc,Doe,fever Headache,[email protected],90000000
    12347,Klu,joe,Sugar, cough and fever,[email protected],12345678
    Please look at the ID's 12345 and 12347. The disease column has a internal comma space between. How do i remove the comma spaces in the disease column, so that it can be loaded from flat file to sql table using SSIS. ?
    Please help !
    Thanks

    Here is a full solution base on my post above (first option)
    1. create temp table (Give it a unique name):
    create table #T (Txt NVARCHAR(MAX))
    GO
    2. Insert all the data into temporary table. Each line in the text file, is a value for one column in a row in the table.
    -- I will jump to the table and use simple insert.
    -- If you have problem with step 1 then please inform us (this is simple bulk insert basically)
    insert #T (Txt) values
    ('1234435,Xyz,Stemit,Brfsdonchitis, Asthma and fever,[email protected],80000000'),
    ('12346,Agjdfjbc,Doge,fevhhhher Headsxdshhache,[email protected],90000000'),
    ('123447,Klu,joe,Sugar, cough and fever,[email protected],12345678')
    GO
    the result should be like this:
    Txt
    1234435,Xyz,Stemit,Brfsdonchitis, Asthma and fever,[email protected],80000000
    12346,Agjdfjbc,Doge,fevhhhher Headsxdshhache,[email protected],90000000
    123447,Klu,joe,Sugar, cough and fever,[email protected],12345678
    I use a SPLIT Function named Split_CLR_Fn. This is a CLR Split function that get input <string to split> and <string as delimiter,> and it return table with 2 columns ID, SplitData
    For example if you use: SELECT * from Split_CLR_Fn('text1,text2,text3,',') then you get result:
    ID SplitData
    1 Text1
    2 Text2
    3 Text3
    ** You can find in the internet several good functions, I HIGHLY RECOMMENDED NOT TO USE T-SQL FUNCTIONS but CLR FUNCTION. Check thi link to understand why:
    http://sqlperformance.com/2012/07/t-sql-queries/split-strings
    ** This is the best function that I know about and I use it, but I change the code a bit to return 2 columns and not just the SplitData as in this blog: http://sqlblog.com/blogs/adam_machanic/archive/2009/04/28/sqlclr-string-splitting-part-2-even-faster-even-more-scalable.aspx
    That's it :-) we are ready for the solution which is very simple
    Solution 1 (BAD solution but easy to write):
    select
    (select SplitData from Split_CLR_Fn(Txt,',') where ID = 1) CustID,
    (select SplitData from Split_CLR_Fn(Txt,',') where ID = 2) FName,
    (select SplitData from Split_CLR_Fn(Txt,',') where ID = 3) LName,
    STUFF((select ',' + SplitData from Split_CLR_Fn(Txt,',') where ID > 3 and ID < (select MAX(ID) from Split_CLR_Fn(Txt,',')) - 1 for XML path('')), 1 , 1,'') Disease,
    (select SplitData from Split_CLR_Fn(Txt,',') where ID = (select MAX(ID) from Split_CLR_Fn(Txt,',')) - 1) Email,
    (select SplitData from Split_CLR_Fn(Txt,',') where ID = (select MAX(ID) from Split_CLR_Fn(Txt,','))) Phone
    from #T
    GO
    Solution 2: better in this case since the format is constant (this is the solution I wrote about above)
    ;With MyCTE as (
    select
    Txt,
    SUBSTRING(Txt, 1, CHARINDEX(',', Txt, 1) - 1) as CustID
    , SUBSTRING(
    Txt
    ,CHARINDEX(',', Txt, 1) + 1 -- I start from the end of preview len
    , CHARINDEX(',', Txt, CHARINDEX(',', Txt, 1)+1)- CHARINDEX(',', Txt, 1) - 1
    ) as FName
    , SUBSTRING(
    Txt
    ,CHARINDEX(',', Txt, CHARINDEX(',', Txt, 1)+1)+1 -- I start from the end of preview len
    , CHARINDEX(',', Txt, CHARINDEX(',', Txt, CHARINDEX(',', Txt, 1)+1)+1) - CHARINDEX(',', Txt, CHARINDEX(',', Txt, 1)+1) - 1
    ) as LName
    , RIGHT(Txt, CHARINDEX(',', REVERSE(Txt), 1) - 1) as Phone
    , RIGHT(LEFT(Txt, Len(Txt) - Len(RIGHT(Txt, CHARINDEX(',', REVERSE(Txt), 1) - 1)) - 1), CHARINDEX(',', REVERSE(LEFT(Txt, Len(Txt) - Len(RIGHT(Txt, CHARINDEX(',', REVERSE(Txt), 1) - 1)) - 1)), 1) - 1) as Email
    from #T
    select CustID,FName,LName, Phone, Email, SUBSTRING(Txt, Len(CustID) + Len(FName) + Len(LName) + 4, Len(Txt) - Len(Email) - LEN(Phone) - Len(CustID) - Len(FName) - Len(LName) - 5) as Disease
    from MyCTE
    I hope that this is useful :-)
      Ronen Ariely
     [Personal Site]    [Blog]    [Facebook]

Maybe you are looking for