Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 firstname lastname switch

Author  Topic 

cDc
Starting Member

30 Posts

Posted - 2004-04-24 : 10:58:26
Hi
does anyone have an sql example of how to convert a string as follows?

"Smith, Bob" becomes "Bob Smith"

Many thanks

ehorn
Master Smack Fu Yak Hacker

1632 Posts

Posted - 2004-04-24 : 12:14:06
[code]declare @name varchar(30)
set @name = 'Smith, Bob'

select ltrim(substring(@name,charindex(',',@name,1)+1,len(@name))) + ' ' + left(@name,charindex(',',@name,1)-1)[/code]
Go to Top of Page
   

- Advertisement -