Amour22015
asked on
TSQL/SQL/Access - Splitting the Full Name from the surname
Hi Experts,
I would like to split or remove the Mr., Ms., Ms, Mr, from the front of the FullName?
I have this in the FullName column:
Mr. John Smith
Ms. Jone Smith
Ms John Smith
I would like:
John Smith
Jone Smith
John Smith
In the FullName column
I have this
Select
LTRIM(RTRIM(SUBSTRING(Full Name, 0, CHARINDEX(' ', FullName)))) As Surname
FROM
[table]
but all that does is gives me another column with Mr. Ms.
and does not take out the Mr. from FullName
I would like either/or/both in Access query or/both TSQL query
Please help and thanks...
I would like to split or remove the Mr., Ms., Ms, Mr, from the front of the FullName?
I have this in the FullName column:
Mr. John Smith
Ms. Jone Smith
Ms John Smith
I would like:
John Smith
Jone Smith
John Smith
In the FullName column
I have this
Select
LTRIM(RTRIM(SUBSTRING(Full
FROM
[table]
but all that does is gives me another column with Mr. Ms.
and does not take out the Mr. from FullName
I would like either/or/both in Access query or/both TSQL query
Please help and thanks...
ASKER
Hi,
That is looking for a parameter @FullName?
So what do I declare the parameter as?
also will this replace it in the FullName column?
Thanks
That is looking for a parameter @FullName?
So what do I declare the parameter as?
also will this replace it in the FullName column?
Thanks
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Kevin Cross,
There is no way of knowing the Mr., Ms.,Mrs., Mis., or even if there is a title in front of the name so matching will not work in this case?
Also what if Mr.John? without any space that was put incorrectly?
So this is not very easy. The good news is that I found out that this Mr. John Smith is ok to have in the column and does not need changing.
so this post has turned into a information post for others to see.
Thanks for helping.
There is no way of knowing the Mr., Ms.,Mrs., Mis., or even if there is a title in front of the name so matching will not work in this case?
Also what if Mr.John? without any space that was put incorrectly?
So this is not very easy. The good news is that I found out that this Mr. John Smith is ok to have in the column and does not need changing.
so this post has turned into a information post for others to see.
Thanks for helping.
Hopefully the thread will stand of an example of why fields should be atomic. Nothing is gained by mushing name parts into a single column and much is lost.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Great thanks
Open in new window