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 |
|
reklan
Starting Member
4 Posts |
Posted - 2004-04-16 : 05:16:43
|
| I have a problem that I cannot seem to solve, so I am asking for help.I have a table that contains the following fieldssurname, fornames, initial, titles etc.Now these fields not only contain single names etc but also contain joint names. i.e.surname | fornames | initial | titlesPearson Dave D MrPearson & Smith Dave & Elaine D & E Mr & Mrs I would like to be able to create a view that would split joint names into new fields ie. Surname2, forenames2 etc.All the joint names are separated by the '&' so names before it stay in the original field and everything after it is put into the new field.Is this possible and can it be done.Many thanksDave |
|
|
AndrewMurphy
Master Smack Fu Yak Hacker
2916 Posts |
Posted - 2004-04-16 : 05:34:38
|
| break this into smaller parts...1. a joint-name field should by the example above have 4 &'s in it2. find the 1st &...and the word after it (id'd by a space either side of it) is the surname3. find the 2nd &...and the word after it (id'd by a space either side of it) is the firstname4. find the 3rd &...and the word/letter after it (id'd by a space either side of it) is the initial5. find the 4th &...and the word after it (id'd by a space either side of it) is the title6. any records with < 4 &....need to have different coding applied.search here using the keywords 'splitting names address'....and you'll come across code snippets which will get you moving along.... |
 |
|
|
|
|
|