Skip to content
Advertisement

SQL: select the last values before a space in a string

I have a set of strings like this:

I need to extract only the last values from the right and before the space, like:

how will the select statement look like? I tried using the below statement, but it did not work.

Advertisement

Answer

Perhaps the simplest method in SQL Server is:

This is perhaps not the most performant method. You probably would use:

Note: If there are no spaces, then to prevent an error:

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