Sort order on a Code type field

KeithMMooreKeithMMoore Member Posts: 59
In a native 4.0 DB the Vendor table "No." field appear to sort in what I consider a fairly natural way:

1
2
10
20
21
30
100
1A
1B

In SQL however that same list goes as

1
1A
1B
10
100
2
20
21
30

Is this simply a reflection of how the native DB handles the code field vs SQL or is there a setting/property I am missing somewhere? Our client would very much prefer the natural order they have enjoyed thus far.

Answers

  • SavatageSavatage Member Posts: 7,142
    One way to always avoid this is to have codes like that all the same length
    so 18 would be
    00001
    00018
    00101
    01560

    Also I read something about changing a value to Variant see posts
    viewtopic.php?f=33&t=21759
    viewtopic.php?f=23&t=4055
  • garakgarak Member Posts: 3,263
    These field is a alphanumeric field with alpha numeric sort order. So, on SQL, not native (Native do it wrong/his own way) the "numeric" sort is not "correct" but the alpha sort is.
    If you need the order 1,2,3,4,5,...,10,11,12....,111,112,113, etc you can set leading Zeros infron of.

    For more infos search also the forum. There are many topics about these theme.

    Regards
    Do you make it right, it works too!
  • KeithMMooreKeithMMoore Member Posts: 59
    Thanks for input - I was afraid that might be the answer :cry: I'll have to break the news to the client this afternoon.
  • ara3nara3n Member Posts: 9,256
    You can change the property "SQL Data Type" to Variant.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • tro#1tro#1 Member Posts: 122
    All,

    I have exactly the same problem.
    The number series setup was not done correctly. And now we have following document numbers in the system:

    VF09-9998
    VF09-9999
    VF09-10001
    VF09-10002
    etc.

    But Sequal sorts it like
    VF08-0999
    VF08-1000
    VF08-10000
    VF08-10001
    ...
    VF08-1001
    VF08-1002
    ...

    That is why I changed the "SQL Data Type" of the Number to Variant.
    Nothing has changed...
    Is there anything else I need to check?

    Thank you in advance.
  • ara3nara3n Member Posts: 9,256
    That property changes the sort if you are only using integers in your code field.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • tro#1tro#1 Member Posts: 122
    Thank you for your answer.

    So I assume I cannot change the sorting that it would also work for alpha-numeric codes...
  • ara3nara3n Member Posts: 9,256
    yes that's correct.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
Sign In or Register to comment.