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)
 Splitting a Column using Stored Proc

Author  Topic 

Tade
Starting Member

5 Posts

Posted - 2010-10-13 : 07:03:47
Hey everyone.
I have a table with the following columns (example):
ID Writers
1 John Doe
2 Doe John
3 Dohn Joe
4 Nohj Eod


I've been looking around to find a script/query/stored procedure that will split the Writers column into two new columns named "FirstName" and "LastName", respectively. All the stored procedures I found were either not good for me (Relied on the fact that the column to split has numbers that follow patterns) Or just plain not worked (Random errors that I couldn't figure out).

I was wondering if someone could help me find a way to reach the above table example, to the following:

ID Writers FirstName LastName
1 John Doe John Doe
2 Doe John Doe John
3 Dohn Joe Dohn Joe
4 Nohj Eod Nohj Eod


Thanks a bunch in advance.

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-10-13 : 07:51:09
We have had this topic yesterday.
Maybe it is an approach?
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=151451


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

Tade
Starting Member

5 Posts

Posted - 2010-10-13 : 09:35:03
Had to play around a bit with the script to match it to my own, but it eventually worked, thanks!
Truly, you are a Flowing Fount of Yak Knowledge.
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-10-13 : 09:54:30
quote:
Originally posted by Tade

Had to play around a bit with the script to match it to my own, but it eventually worked, thanks!
Truly, you are a Flowing Fount of Yak Knowledge.


thx


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page
   

- Advertisement -