Ver Mensaje Individual
  #2 (permalink)  
Antiguo 03/09/2009, 20:55
Avatar de Beakdan
Beakdan
 
Fecha de Ingreso: diciembre-2001
Ubicación: Monterrey, Nuevo León
Mensajes: 433
Antigüedad: 23 años, 2 meses
Puntos: 7
Respuesta: Comparar cadenas

No estás haciendo mal nada. Así está definido en el estándar SQL92, el cual cito:
Código:
8.2  <comparison predicate>
General Rules
...
3) The comparison of two character strings is determined as fol-
            lows:

            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>.
En pocas palabras, la longitud de @var es 5, mientras que la longitud de @var2 es 8. Puesto que la primera es menor que la segunda, una copia de la primera debe ser completada hasta una longitud de 8 con espacios y comparada con la segunda, resultando así "true" en la comparación.

Saludos.

Pd: CS --> Collating Sequence

Última edición por Beakdan; 03/09/2009 a las 20:57 Razón: Faltó el significado de un acrónimo.