Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. The text,ntext and image data type cannot be compared or sorted except when IS NULL or LIKE

The text,ntext and image data type cannot be compared or sorted except when IS NULL or LIKE

Scheduled Pinned Locked Moved ASP.NET
databasehelpsql-serversysadmin
3 Posts 2 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    haleemasher
    wrote on last edited by
    #1

    here is my query and i use it for making a crystal report when i run it in database MS Access it show the values but same query when i run it in sql server it show error "The text,ntext and image data type cannot be compared or sorted except when IS NULL or LIKE" there are its datatypes TotalSale int Price money Category Text Transaction Text same datatype used in sqlserver and MS access. Plz help

    SELECT Sum(b.TotalSale*b.Price) AS total, a.Category , a.[Transaction]
    FROM TransactionType AS a INNER JOIN CouponTransaction AS b ON a.TransactionTypeID = b.TransactionTypeID
    GROUP BY a.Category,a.[Transaction];

    N 1 Reply Last reply
    0
    • H haleemasher

      here is my query and i use it for making a crystal report when i run it in database MS Access it show the values but same query when i run it in sql server it show error "The text,ntext and image data type cannot be compared or sorted except when IS NULL or LIKE" there are its datatypes TotalSale int Price money Category Text Transaction Text same datatype used in sqlserver and MS access. Plz help

      SELECT Sum(b.TotalSale*b.Price) AS total, a.Category , a.[Transaction]
      FROM TransactionType AS a INNER JOIN CouponTransaction AS b ON a.TransactionTypeID = b.TransactionTypeID
      GROUP BY a.Category,a.[Transaction];

      N Offline
      N Offline
      Nigel Ferrissey
      wrote on last edited by
      #2

      You can't GROUP BY a field of type text. You could cast Category to a varchar, but that would not perform well. Are you sure that the type text is the most appropriate for your data? A varchar might be much better and your GROUP BY would then work.

      H 1 Reply Last reply
      0
      • N Nigel Ferrissey

        You can't GROUP BY a field of type text. You could cast Category to a varchar, but that would not perform well. Are you sure that the type text is the most appropriate for your data? A varchar might be much better and your GROUP BY would then work.

        H Offline
        H Offline
        haleemasher
        wrote on last edited by
        #3

        thnx Nigel now its working when i change its datatype. again thank u very much

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups