Welcome to Sign in | Help

Re: Comportament varchar/char

  •  01-09-2007, 9:32 AM

    Re: Comportament varchar/char

    Comportamentul SQL Server la compararea unor expresii de tip caracter este documentat la: http://msdn2.microsoft.com/en-us/ms189863.aspx

    În această pagină se face referire şi la standardul SQL-92. Un draft aproape final al acestui standard e disponibil la adresa: http://www.contrib.andrew.cmu.edu/~shadow/sql/sql1992.txt (standardul oficial e disponibil contra cost de la ISO sau ANSI).

    După câte înţeleg eu, situaţia e puţin invers: nu se scot spaţiile, ci se adaugă. Vezi punctul 3) din secţiunea 8.2 <comparison predicate> a standardului:

                The comparison of two character strings is determined as follows:

    a) If the length in characters of X is not equal to the length
    in characters of Y, then the shorter string is effectively
    replaced, for the purposes of comparison, with a copy of
    itself that has been extended to the length of the longer
    string by concatenation on the right of one or more pad char-
    acters, where the pad character is chosen based on CS. If
    CS has the NO PAD attribute, then the pad character is an
    implementation-dependent character different from any char-
    acter in the character set of X and Y that collates less
    than any string under CS. Otherwise, the pad character is a
    <space>.

    b) The result of the comparison of X and Y is given by the col-
    lating sequence CS.

    c) Depending on the collating sequence, two strings may com-
    pare as equal even if they are of different lengths or con-
    tain different sequences of characters. When the operations
    MAX, MIN, DISTINCT, references to a grouping column, and the
    UNION, EXCEPT, and INTERSECT operators refer to character
    strings, the specific value selected by these operations from
    a set of such equal values is implementation-dependent.

    Răzvan

View Complete Thread
Powered by Community Server (Commercial Edition), by Telligent Systems