Results 1 to 3 of 3

Thread: varchar type

  1. #1
    Join Date
    Nov 2003
    Posts
    68

    Unanswered: varchar type

    hi,
    I want to order my varchar from alphanumeric to numeric
    ex : ABCD....Z0123456789..
    rather than
    0123456789...ABCD..Z

    for one session.

    How can i do this.
    There is a database parameter to do that ?

  2. #2
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    One rather sneaky way to do that would be to use an EBCDIC collation, which is what it sounds like you are trying to do anyway.

    -PatP

  3. #3
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    Code:
    USE Northwind
    GO
    
    CREATE TABLE myTable99(Col1 char(1))
    GO
    
    INSERT INTO myTable99(Col1)
    SELECT '0' UNION ALL
    SELECT '1' UNION ALL
    SELECT '2' UNION ALL
    SELECT '3' UNION ALL
    SELECT '4' UNION ALL
    SELECT '5' UNION ALL
    SELECT '6' UNION ALL
    SELECT '7' UNION ALL
    SELECT '8' UNION ALL
    SELECT '9' UNION ALL
    SELECT 'A' UNION ALL
    SELECT 'B' UNION ALL
    SELECT 'C' UNION ALL
    SELECT 'D'
    GO
    
    SELECT * FROM myTable99 
    ORDER BY CASE WHEN Col1 BETWEEN '0' AND '9' THEN 2 ELSE 1 END, COl1
    GO
    
    DROP TABLE myTable99
    GO
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •