Options

SQL Variant

megawavezmegawavez Member Posts: 133
edited 2010-06-19 in SQL General
Hi,

I thinking of using this to solve the sorting problem inherent in SQL (10 sorts before 2). Are there any drawbacks to doing this? I haven't been able to find any in depth pluses or minuses on this subject in the forum. I'm planning on changing the "Sales Header"."Document No." and Job."No." fields to SQL Type = Variant.

Thanks,
Mega

Comments

  • Options
    megawavezmegawavez Member Posts: 133
    Opps... make that "Sales Header"."No."
  • Options
    strykstryk Member Posts: 645
    Well, the advantage of using the "SQLDataType" "Variant" is that you are back to the old/native numeric sorting (thus filtering!) and you still could use alphanumeric values ...

    Downsides are these:
    + When using "Variant" SQL Server has to do implicitly internal datatype-conversions, which could slightly degrade performance (depending on the business processes)
    + You cannot use any "leading zeros" like 01, 001, 0001 etc. in Primary Keys (as "Sales Header"."No."), this all would create a "Variant" of 1 (hence a PK violation)
    Jörg A. Stryk (MVP - Dynamics NAV)
    NAV/SQL Performance Optimization & Troubleshooting
    STRYK System Improvement
    The Blog - The Book - The Tool
  • Options
    megawavezmegawavez Member Posts: 133
    stryk wrote:
    Well, the advantage of using the "SQLDataType" "Variant" is that you are back to the old/native numeric sorting (thus filtering!) and you still could use alphanumeric values ...

    Downsides are these:
    + When using "Variant" SQL Server has to do implicitly internal datatype-conversions, which could slightly degrade performance (depending on the business processes)
    + You cannot use any "leading zeros" like 01, 001, 0001 etc. in Primary Keys (as "Sales Header"."No."), this all would create a "Variant" of 1 (hence a PK violation)

    Thanks !
  • Options
    kinekine Member Posts: 12,562
    And you cannot use big numbers like "2010016546544" because they will "overflow" the maxint during the conversion.
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
Sign In or Register to comment.