Q:

SQL Server 2016: How to read different substrings from a text with special characters

I have a string with the value 'Initiator;abcd@gmail.com'.
I would like to read these two fields in two separate queries.
';' would be the delimiter always.
I used the below query and it works for fetching the email. However it looks overcomplicated to me.
select SUBSTRING(NOTES (CHARINDEX(';',NOTES,1)+1),LEN(NOTES))
from DOCUMENT
where DOC_ID = '12345'

Can someone please help in simplifying it and reading both the values.
Thanks in advance.

A:

First, your query looks fine for email but it has incorrect syntax, second just use left() with charindex() to get the first part :
select left(notes, charindex(';', notes)-1), 
       substring(notes, charindex(';', notes)+1, len(notes))
from document
where doc_id = 12345;

