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 |
|
erica686
Starting Member
13 Posts |
Posted - 2010-02-09 : 02:04:01
|
| I need to select numerals (and decimals) only from a text string. the field (varchar) can contain any text eg: PH - 15.0HRS. I need to filter out the '15.0' only. Any ideas how to do this?Note that I also need the decimal place. Otherwise, the numerals will always start on the 6th character, and the last 3 characters will always be 'HRS' - maybe I could use this to create a query to filter out the numbers?Thanks |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2010-02-09 : 02:08:11
|
fnFilterStringor if the numeric is in fixed position then you can use SUBSTRING() to extract it KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
erica686
Starting Member
13 Posts |
Posted - 2010-02-09 : 02:15:32
|
| the numeric will always start on character 6, but the numeric part could be 3-5 characters long depending on the number (7.5 or 56.5 or 123.1).Is there a function i can use to remove the first 5 characters, and remove the last 3 characters? |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2010-02-09 : 02:26:20
|
[code]select substring(col, 6, len(col) - 8)[/code] KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
|
|
|