SQL Split function.
Posted
by Wardy
on Stack Overflow
See other posts from Stack Overflow
or by Wardy
Published on 2010-05-20T09:11:23Z
Indexed on
2010/05/20
9:20 UTC
Read the original article
Hit count: 333
Hi guys,
I'm looking for a way to do this ...
SELECT FirstName, LastName, Split(AddressBlock, ' ', 1), Split(AddressBlock, ' ', 2), PostCode
FROM Contacts
The arguments I want to pass are ...
- The address
- The separator (current situation requires 2 spaces but this might be a comma or a space followed by a comma) or something else (it varies).
- The address part I want to return (i don't always need all parts of the split result).
I seem to be able to find a few examples of splitting functions about the internet but they return a table containing the entire set of split parts.
My SQL skills aren't that great so I need the answer to be ultra simple. I'm always working with nvarchar data and the function needs to be reusable.
© Stack Overflow or respective owner