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 |
|
drpkrupa
Yak Posting Veteran
74 Posts |
Posted - 2006-10-03 : 21:30:11
|
| on my select statment i want a use sustring which start with very first chracter as number and last charcter as space.CA 1123 noel34434 s madissionhouse no 39484 waterfalli need result as11233443439484substring first letter with number and last with space. |
|
|
drpkrupa
Yak Posting Veteran
74 Posts |
Posted - 2006-10-03 : 22:11:56
|
| i found this patindex('%[0-9]%',addr1) to get first numeric chacter.I am thinking to user thissubstring(addr1,patindex('%[0-9]%',addr1),?????)??? - how can i end when i find space or non numric no .like kdhfd 22232 kjjjljk 34343kkki need 22232 and 34343break on space or alpha . |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-10-03 : 22:21:57
|
[code]select *, n = substring(col, patindex('%[0-9]%', col), charindex(' ', col, patindex('%[0-9]%', col)) - patindex('%[0-9]%', col))from( select 'CA 1123 noel' as col union all select '34434 s madission' union all select 'house no 39484 waterfall') dcol n ------------------------ ------------------------ CA 1123 noel 112334434 s madission 34434house no 39484 waterfall 39484[/code] KH |
 |
|
|
drpkrupa
Yak Posting Veteran
74 Posts |
Posted - 2006-10-04 : 10:53:10
|
| Thanks for you replay.I am very close to my result.two more question.it get failed on this:'noel st 1223' - because there is no spacei want a make small change. What i want do i want a look first letter after number or space after number. Who ever find first then i want a break at that point.Like: 'noel 1236 st' -- 1236 - space first'noel 1236st street' ---- 1236 -- st -letter before space'noel 1236' --- 1236 - no space or letter after no'noel 1236st' --- 1236 - first letter st after 1236Need help please |
 |
|
|
drpkrupa
Yak Posting Veteran
74 Posts |
Posted - 2006-10-04 : 12:47:24
|
| any update. thanks in advance. |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
|
|
|
|
|
|
|