Link to home
Start Free TrialLog in
Avatar of Answering4uAnt
Answering4uAntFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Delete Characters After a Space in a String

I have had a quick search but can't seem to get a working method of this, and I can't imagine it is the most difficult thing to do.
I have a list of about 1000 names from a client, all in the 'surname, forename' format.
I am loading them into a database but want them to be in the 'Forename Surname' format.
I have managed to get some working code to get the forename only but now need something that will get the surname only, and a way to do that is get delete all characters after and including the comma.

Cheers in advance
Avatar of Answering4uAnt
Answering4uAnt
Flag of United Kingdom of Great Britain and Northern Ireland image

ASKER

sorry topic title slightly wrong, I want to delete all characters after a comma but imagine the method will be pretty much the same

Cheers
ASKER CERTIFIED SOLUTION
Avatar of bokist
bokist
Flag of Hungary image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks, that did the job just fine, it did leave an extra space at the start which I have managed to remove easily enough

cheers
declare @name varchar(50)
set @name='Ritesh,Shah'
select replace(@name,substring(@name,charindex(',',@name),len(@name)),'')