I am working on a table, where the data of a field is stored as follows:
Anexo 1|06/04/2020|06/06/2025
I need to extract only what is found up to the first |
, but I still can't get it. I tried it with charindex and a substring, but the query returns information starting from the last |
one it finds.
How can I perform this query?
I add my code that I have:
SELECT SUBSTRING(
LCD.DATOS,CHARINDEX('|',LCD.DATOS)-10,
LEN(LCD.Datos)-CHARINDEX('|',LCD.Datos)
FROM Mitabla AS LCD
You have to indicate that you are going to start from
0
( zero ) to the first occurrence of|
Example:
Demo