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 |
|
real_pearl
Posting Yak Master
106 Posts |
Posted - 2004-09-10 : 07:05:32
|
| is there a way to sort in a way that 10 will come after 9 but not just after 1I mean in this way12345678910 but not like this11023456789 |
|
|
Lumbago
Norsk Yak Master
3271 Posts |
Posted - 2004-09-10 : 07:09:12
|
| The first one is a numeric sort, the second is an alphabetical sort. You can either convert this field in to a numeric datatype or do something like this:ORDER BY CAST('00000000' + Field AS varchar(8))--Lumbago"Real programmers don't document, if it was hard to write it should be hard to understand" |
 |
|
|
mwjdavidson
Aged Yak Warrior
735 Posts |
Posted - 2004-09-10 : 07:10:25
|
| Yes - use a numeric datatype (i.e. TINYINT, SMALLINT, INT, etc).If you are storing these values in a VARCHAR/NVARCHAR field, you will have to convert them in your query:SELECT MyTable.MyColumnFROM MyTableORDER BY CONVERT(SMALLINT, MyTable.MyColumn)Mark |
 |
|
|
|
|
|