When entering numerical data into a SQL DB, what data type is best used to sort numerically, (ASC or DESC...in doesn't matter,) so that the data sorts numerically correct?
For example, say I have entered the following data in a table called 'Catalog' within the "Inventory" DB. The Data Type for 'Catalog' is NCHAR.
1, 2, 3, 100, 101.1, 101.2, 200, 201, 201.1, 300, 301.1
I then run this query:
Use Data;
Select *
From Inventory
Order By Catalog;
I then get the result of table 'Catalog' displayed as:
1
100
101.1
101.2
2
200
201
201.1
3
300
301.1
I would like to have it ordered as:
1
2
3
100
101.1
101.2
200
201
201.1
300
301.1
I know using leading zeros work in NCHAR, but is there a better method?