Hello,
Using T-SQL r2008.
I have a long list of names that looks something like this:
Joe.Blow(797),
Fred.Rodney(801),
Melody.Razza(621),
John McEnroe,
Hamza El Din,
Johnny.Rotten,
...
I need to remove everything past the first '(', as well as replace the '.' with a space so that all names appear simply as "FirstName LastName". (As you can see, some names contain the offending characters and some do not.)
I've tried the following in my SELECT statement:
CASE
WHEN CHARINDEX('(',[AMA_WEBUSERID])>0
THEN LEFT([AMA_WEBUSERID], CHARINDEX('(', [AMA_WEBUSERID]) - 1)
WHEN CHARINDEX('.',[AMA_WEBUSERID])>0
THEN REPLACE([AMA_WEBUSERID],'.',' ')
ELSE [AMA_WEBUSERID]
END AS [AMA_WEBUSERID]
The first WHEN works as expected, so "Joe.Blow(797)" appears as "Joe.Blow"; however the period is still there.
I tried a couple of different combinations using AND to try to combine the functions, but all of them gave me syntax errors.
Any help appreciated!
Jens