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 |
|
SoniaGupta
Starting Member
1 Post |
Posted - 2008-03-07 : 06:10:15
|
| I have the column of type string in the databaseFollowing is the data in that column12111221abcIf i sort the table with the help of this column then the output come in the following manner11112221abccan i improve the order actually i want the output like 1 2 11 12 21 abc |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-03-07 : 08:07:11
|
| Always use proper datatype to store dataUse one of these1 Order by cast(col as int)2 order by len(col),col3 order by col*1MadhivananFailing to plan is Planning to fail |
 |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2008-03-07 : 09:11:07
|
| Madhivanan -- he's got some alphas in there, too, it looks like.One way is to pad it with leading zeroes or spaces and then sortorder by right('0000000000' + col, 10)- Jeffhttp://weblogs.sqlteam.com/JeffS |
 |
|
|
|
|
|