| Author |
Topic |
|
hongho2
Starting Member
6 Posts |
Posted - 2005-10-25 : 23:30:59
|
| I have the data from table look like thisBryan W Lee1Jim Brook1I want it to return with is formatFNAME LNAME MI===== ===== ===Bryan Lee WJim Brook Here is my syntax but it not quite wokring correctlyselect namefrom acctSELECT LName = CASE WHEN PARSENAME(REPLACE(name, ' ', '.'), 3) IS NULL THEN ''ELSE PARSENAME(REPLACE(name, ' ', '.'), 1) END, FName = CASE WHEN PARSENAME(REPLACE(name, ' ', '.'), 3) IS NULL THEN PARSENAME(REPLACE(name, ' ', '.'), 2)ELSE PARSENAME(REPLACE(name, ' ', '.'), 3) END, MName = CASE WHEN PARSENAME(REPLACE(name, ' ', '.'), 3) IS NULL THEN PARSENAME(REPLACE(name, ' ', '.'), 1) ELSE PARSENAME(REPLACE(name, ' ', '.'), 2)ENDFROM acctThanks |
|
|
blindman
Master Smack Fu Yak Hacker
2365 Posts |
Posted - 2005-10-26 : 00:07:21
|
| Not sure what the "1"s are doing in your data (Lee1? Brook1?), but if you use REPLACE() to clear these out, then you can use this function to parse the name strings:http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=56499The syntax would be:dbo.FormatName([YourString], 'F') as FNAME,dbo.FormatName([YourString], 'm') as MI,dbo.FormatName([YourString], 'L') as LNAME |
 |
|
|
hongho2
Starting Member
6 Posts |
Posted - 2005-10-26 : 10:44:47
|
| I am not sure what you said. In your function, there is @TempString in ('VAN', 'VON', 'MC', 'Mac', 'DE')??? My case was diffrent.Thanks |
 |
|
|
blindman
Master Smack Fu Yak Hacker
2365 Posts |
Posted - 2005-10-26 : 11:26:38
|
| So, you didn't actually TRY it, did you? |
 |
|
|
hongho2
Starting Member
6 Posts |
Posted - 2005-10-26 : 14:33:04
|
| No, because I didn't understand.thanks |
 |
|
|
|
|
|