How do I sort a VARCHAR column in SQL server that contains numbers?

后端 未结 11 2003
慢半拍i
慢半拍i 2020-11-27 14:08

I have a VARCHAR column in a SQL Server 2000 database that can contain either letters or numbers. It depends on how the application is configured o

11条回答
  •  被撕碎了的回忆
    2020-11-27 14:19

    This seems to work:

    select your_column  
    from your_table  
    order by   
    case when isnumeric(your_column) = 1 then your_column else 999999999 end,  
    your_column   
    

提交回复
热议问题