Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

String Split using the '|' delimiter

I have string values and I want to remove last numbers from that string.
My data set is as below:

AAB|LG|-|AE|CPL|C|SS|M|1.25
AAB|GU|-|NT|GU|O|3TOL|S|1.00
BT|KK|-|KK|-|N|M|-|1
CCB|EX|-|CPL|-|N/A|M|-|1.0

I want to get the data set as below:

AAB|LG|-|AE|CPL|C|SS|M|
AAB|GU|-|NT|GU|O|3TOL|S|
BT|KK|-|KK|-|N|M|-|
CCB|EX|-|CPL|-|N/A|M|-|

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

SELECT 
  LEFT(ModifiedString, LEN(ModifiedString) - CHARINDEX('|', REVERSE(ModifiedString)) + 1) 
  AS trimmed_string
FROM temp;

Demo: https://dbfiddle.uk/WdTxDw8D

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading