How do I get by with "The text, ntext, and image data types cannot be compared or sorted, except when using IS NULL or LIKE operator."

  • select ID_NUM as ID_num, LAME1, RESP_CODE as RESP_CODE1,cast(QUERY_COMM as nvarchar(max)) as QUERY_COMM1

    from dbo.DRGQueries

    group by ID_NUM, LAME, RESP_CODE,QUERY_COMM

    having COUNT(*) >1

    where I have Query_comm as ntext as datatype and

    Resp_code nvarchar(50) in the above table.

    I am getting the error message

    "The text, ntext, and image data types cannot be compared or sorted, except when using IS NULL or LIKE operator."

    Thanks,

    Haimanti

  • Like this (you were half way there).

    select

    ID_NUM as ID_num,

    LAME1,

    RESP_CODE as RESP_CODE1,

    cast(QUERY_COMM as nvarchar(max)) as QUERY_COMM1

    from

    dbo.DRGQueries

    group by

    ID_NUM,

    LAME,

    RESP_CODE,

    cast(QUERY_COMM as nvarchar(max))

    having

    COUNT(*) > 1;

  • Thanks so much!

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply