Results 1 to 3 of 3
  1. #1
    Join Date
    Aug 2003
    Posts
    23

    Unanswered: error in image field when using CASE statement

    I've this Stored procedure on a SQLserver 2000 SP3:


    SELECT *,CASE immagine WHEN NULL THEN 0 ELSE 1 END AS hasImage
    FROM Squadre WHERE squadra = @squadra

    this is a flag that returns if the image field is present or not..
    i've a lot of this type of stored procedures.. but this one returns me an error..

    ---------------------------
    Microsoft SQL-DMO (ODBC SQLState: 42000)
    ---------------------------
    Errore 306: The text, ntext, and image data types cannot be compared or sorted, except when using IS NULL or LIKE operator.
    ---------------------------
    OK
    ---------------------------

    An i can't save.. why?
    reme,ber that in the same Db there's other Stored like this.. the same syntax and the same field or table.. can anyone help me??
    Alx_81 =)

  2. #2
    Join Date
    Jul 2003
    Location
    San Antonio, TX
    Posts
    3,662
    So, are you saying that "sometimes" it works and sometimes it doesn't?

    This should work "always":

    SELECT *,CASE WHEN immagine IS NULL THEN 0 ELSE 1 END AS hasImage
    FROM Squadre WHERE squadra = @squadra

    But exclude the image field from the SELECT list, unless you really intend to use it.
    "The data in a record depends on the Key to the record, the Whole Key, and
    nothing but the Key, so help me Codd."

  3. #3
    Join Date
    Aug 2003
    Posts
    23

    Re:

    i must use it!!!
    Alx_81 =)

Posting Permissions

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