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 |
|
eddy556
Starting Member
36 Posts |
Posted - 2009-01-16 : 06:21:22
|
| Now I know this looks simple at first glance but I need your ideas.I have a stored procedure which output data similar to the following:Consider urine checks (reg11),If usingengineering controls/non disposable RPE ensure maintenance(reg 9),Consider monitoring (reg 10),Consider end tidal breath tests (Reg 11).I need to order them based on the (Reg xx) ASCThere are no other values by which I can order them (i.e. textcode or whatever) so the only other way I can see is somehow parse the xx bit out and order via that? |
|
|
Jai Krishna
Constraint Violating Yak Guru
333 Posts |
Posted - 2009-01-16 : 06:24:58
|
| ORDER BY CAST(RIGHT(RTRIM(col),2) AS INT)ORORDER BY CONVERT(INT, RIGHT(RTRIM(col),2))ORORDER BY CAST (SUBSTRING(col,CHARINDEX(' ',col,1)+1,LEN(col)) AS INT)col is ur column name which contains reg 10.........Jai Krishna |
 |
|
|
eddy556
Starting Member
36 Posts |
Posted - 2009-01-16 : 06:32:37
|
| WOW you guys know your stuff! Many thanks! |
 |
|
|
Jai Krishna
Constraint Violating Yak Guru
333 Posts |
Posted - 2009-01-16 : 06:38:11
|
| WelcomeJai Krishna |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-01-16 : 07:18:50
|
| orORDER BY RIGHT(RTRIM(col),2)*1MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|