Click here to Skip to main content
15,921,959 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi Team,

I want to know how to apply sorting for my varchar column.
my database column datatype is varchar the records looks like (01,02,03,04,10,11,50,100,101...) instead of (01,02,03,04,10,11,100,101,50,...).
if i set datatable column as number means the values changed like (1,2,,3 not 01,02,03).
i cant able to change the database column type so i need to sort this varchar column with format of ("00").
help me guys
Posted

1 solution

select CONVERT(int,YourColumn) as bla  , YourColumn  
 from YourTable
 order by bla
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900