select * from tablename order by checksum(colunname)

解决方案 »

  1.   

    看错
    select * from tablename order by ascii(colunname)
      

  2.   

    create table #(name varchar(10))
    insert into # select '0005-4'
    insert into # select '00053'select * from #
    /*
    name
    ----------
    0005-4
    00053
    */
    select * from #
    order by name 
    /*
    name
    ----------
    00053
    0005-4
    */
    select * from #
    order by ascii(name)  /*
    name
    ----------
    0005-4
    00053
    */
      

  3.   

    select ascii('-'),ascii('4')DECLARE @t TABLE(v VARCHAR(100))
    INSERT @t SELECT '00534'
    UNION ALL SELECT '0053-4'SELECT * FROM @t ORDER BY vSELECT * FROM @t ORDER BY v COLLATE Albanian_BIN