sql server string parsing?

Assuming it’s just the two emails and one comma, try the following:

DECLARE @Test table ( line varchar(500) );
INSERT INTO @Test VALUES
    ( '1194125598,,191,3.95,194.95,Loan Payment,999999999,2779,"Melinda","Meeken",99999999,"[email protected] , [email protected]",10/28/2020 11:13' );

SELECT
    STUFF (
        line,
        CHARINDEX ( ',', line, CHARINDEX ( '@', line ) ),
        1,
        ''
    ) AS new_line
FROM @Test;

Returns

+-----------------------------------------------------------------------------------------------------------------------------------------------+
|                                                                   new_line                                                                    |
+-----------------------------------------------------------------------------------------------------------------------------------------------+
| 1194125598,,191,3.95,194.95,Loan Payment,999999999,2779,"Melinda","Meeken",99999999,"[email protected]  [email protected]",10/28/2020 11:13 |
+-----------------------------------------------------------------------------------------------------------------------------------------------+

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top