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 |
|
paha
Starting Member
3 Posts |
Posted - 2011-01-11 : 03:03:13
|
| Table has one column (col1) with data like :aaa_10_morechars1aaaa_111_muchmorecharsa_121234_bignothing_morecharsI need to show only the number in the middle from those strings.This query gives me the start position of the number: SELECT SUBSTRING(col1,CHARINDEX('_',col1)+1,LEN(col1)) FROM tablebut my brain crashed after trying to get last number position. |
|
|
paha
Starting Member
3 Posts |
Posted - 2011-01-11 : 04:07:29
|
| My solution :SELECT SUBSTRING( SUBSTRING(col1,CHARINDEX('_',col1)+1,LEN(col1)),0,CHARINDEX('_',SUBSTRING(col1,CHARINDEX('_',col1)+1,LEN(col1))))FROM TableAnyone got something shorter and simpler xD |
 |
|
|
MIK_2008
Master Smack Fu Yak Hacker
1054 Posts |
Posted - 2011-01-11 : 04:39:28
|
| not yet will let you know if got one ;) |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
|
|
|