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 |
|
sardinka
Posting Yak Master
142 Posts |
Posted - 2005-01-26 : 11:13:09
|
| I have a fields with the space char in data.How to find a space character in query?'Smith David' |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2005-01-26 : 11:31:21
|
select * from MyTablewhere charindex(' ', col1) > 0Go with the flow & have fun! Else fight the flow |
 |
|
|
sardinka
Posting Yak Master
142 Posts |
Posted - 2005-01-26 : 11:38:01
|
| Sorry... I didn't clear my question....I need to create a 2 columns from 1 columns where space isExample:'Smith David''Smith' 'David' |
 |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2005-01-26 : 11:43:49
|
[code]declare @b varchar(50)set @b = 'john smith'select parsename(replace(@b, ' ', '.'), 2) as First_Name, parsename(replace(@b, ' ', '.'), 1) as Last_Nameselect left(@b, charindex(' ', @b)-1) as First_Name, substring(@b, charindex(' ', @b)+1, len(@b)) as Last_Name[/code]Go with the flow & have fun! Else fight the flow |
 |
|
|
sardinka
Posting Yak Master
142 Posts |
Posted - 2005-01-26 : 14:49:17
|
| it didn't work for if MI exist.Kath M. Smith |
 |
|
|
Bustaz Kool
Master Smack Fu Yak Hacker
1834 Posts |
Posted - 2005-01-26 : 15:58:01
|
| Define your requirements.HTH=================================================================Our elections are free, it's in the results where eventually we pay. -Bill Stern, sports announcer (1907-1971) |
 |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2005-01-26 : 16:36:29
|
well that's a little harder. you need to parse out 3 strings.play with charindex and substring. my examples should give you some ideas...Go with the flow & have fun! Else fight the flow |
 |
|
|
|
|
|
|
|