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 2005 Forums
 Transact-SQL (2005)
 fullname

Author  Topic 

khusiie
Yak Posting Veteran

78 Posts

Posted - 2009-09-22 : 12:00:08
i have fullname - one column in a table and i want to differentiate first name and last name(two columns) from that fullname - one column

example:
its

id,fullname, date,quantity
---------------------------
1 William Guard 1/1/2006 25.00
2 Rhodes Jason 4/14/2007 523.00
3 Helley Simpson 9/25/2008 0.0

i want like-

id firstname lastname date quantity
---------------------------------------
1 William Guard 1/1/2006 25.00
2 Rhodes Jason 4/14/2007 523.00
3 Helley Simpson 9/25/2008 0.0

how can i get firstname and lastname from fullname?

thanks



Hommer
Aged Yak Warrior

808 Posts

Posted - 2009-09-22 : 12:25:31
well, for the example data, it wouldn't be too hard. You could plit them up by the space.
however, I suspect your real data is more complex. Contains something like these:

Such as
Ed Smith II
Dr. Al Smith
Dave A. Smith
Marry Ann Smith
Go to Top of Page

blindman
Master Smack Fu Yak Hacker

2365 Posts

Posted - 2009-09-24 : 15:33:25
This function will split complex names into their components:
http://sqlblindman.pastebin.com/f68f37c15


________________________________________________
If it is not practically useful, then it is practically useless.
________________________________________________
Go to Top of Page
   

- Advertisement -