Skip to content
Advertisement

T-SQL split string based on delimiter

I have some data that I would like to split based on a delimiter that may or may not exist.

Example data:

I am using the following code to split this data into First and Last names:

The results I would like:

This code works just fine as long as all the rows have the anticipated delimiter, but errors out when a row does not:

How can I re-write this to work properly?

Advertisement

Answer

May be this will help you.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement