December 5, 2013 at 12:36 pm
One column name as [MemberName] in which stored data like
LastName, FirstName M (with initial middle name)
or
LastName, FirstName (without initial middle name)
How to create a function to split out two columns [First name] and [Last name]?
December 5, 2013 at 12:44 pm
Something like this?
WITH CTE([MemberName])AS(
SELECT 'Cazares, Luis' UNION ALL
SELECT 'Cazares, Luis A')
SELECT LEFT( MemberName, CHARINDEX(',', MemberName) - 1) LastName,
SUBSTRING( MemberName, CHARINDEX(',', MemberName) + 1, LEN( MemberName)) FirstName
FROM CTE
December 5, 2013 at 12:53 pm
Thank you for help.
We are getting there but if MemberName is 'Cazares, Luis A' I want to display as 'Cazares, Luis' as well.
How modify code?
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply