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.
| Author |
Topic |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2003-03-07 : 07:34:39
|
| Brian writes "Forenames in my HR database are held in only one field. I want to split the forenames into seperate columns in a select query. There is no way to tell whether there are one, two or perhaps even three forenames in the field. Eg: a select on forenames could expose:Brian DavidJamesMichael Roger John I have tried substring, charindex but keep missing the target.Could you laugh at me and then let me know what to do." |
|
|
Page47
Master Smack Fu Yak Hacker
2878 Posts |
Posted - 2003-03-07 : 07:49:17
|
| Please provide ddl (create table statement), and insert dml to populate with the sample data. Then describe the expected rowset of the query.This can be done, but it is important to frame the problem correctly so that all the requirements are accounted for.Jay White{0} |
 |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2003-03-07 : 07:55:17
|
| Brian --Also, take a look at:http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=24277Ignore some of the "friendly bantering" and there are some solutions on how to parse a field into multiple fields... Just rewrite the code to delimit using spaces instead of commas....- Jeff |
 |
|
|
Page47
Master Smack Fu Yak Hacker
2878 Posts |
Posted - 2003-03-07 : 08:03:30
|
| If you use the above link, you'll need to asses the max number of forenames in your data so that you can construct the proper update query.If the number for forenames is truely variable and limitless, there may be some interesting ways to accomplish the task in an even more dynamic way ...Jay White{0} |
 |
|
|
|
|
|