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
 SQL Server Development (2000)
 How to parse field "LastName,FirstName"

Author  Topic 

IronGiant
Starting Member

1 Post

Posted - 2007-12-07 : 19:48:36
Hello, I need some help being pointed in the right direction. I have a field in my Customer table called name that is "LastName,FirstName". I need to be able to return a result set with "FirstName,LastName". Any ideas?

dinakar
Master Smack Fu Yak Hacker

2507 Posts

Posted - 2007-12-08 : 00:32:32
Use CHARINDEX to get the position of ',' and SUBSTRING to get the rest of the string as FirstName.

Dinakar Nethi
************************
Life is short. Enjoy it.
************************
http://weblogs.sqlteam.com/dinakar/
Go to Top of Page

kiruthika
Yak Posting Veteran

67 Posts

Posted - 2007-12-08 : 02:41:46
hi!

select fname+','+lname as NameOfPerson from mytable

kiruthika
http://www.ictned.eu
Go to Top of Page

kiruthika
Yak Posting Veteran

67 Posts

Posted - 2007-12-08 : 02:47:57
hi!

sorry for the wrong reply
Go to Top of Page

jezemine
Master Smack Fu Yak Hacker

2886 Posts

Posted - 2007-12-08 : 23:30:43
bad design. your column should be separated into two columns.


elsasoft.org
Go to Top of Page
   

- Advertisement -