Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2009
    Posts
    3

    Unanswered: Another group by ntext

    I'm trying to run a query with group by on NTEXT.
    I saw the solution written on
    http://www.dbforums.com/microsoft-sq...xt-column.html to cast the ntext to varchar
    and now I'm running the query:

    " SELECT name, xmlFields, MAX(accountId)
    FROM tblQueries
    GROUP BY name, CAST(xmlFields as varchar(8000)) "

    where xmlFields is my ntext fields
    but I getting an error message:
    Error 8120: Column 'xmlFields' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.

  2. #2
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    The message is correct - xmlFields is in the select list but not in the GROUP BY clause. In the group by clause you have another column entirely: CAST(xmlFields as varchar(8000) is not the same as xmlFields

    BTW - my hope is that is enough of a hint to guide your thinking to the solution - always better than just being handed it
    Testimonial:
    pootle flump
    ur codings are working excelent.

  3. #3
    Join Date
    Nov 2009
    Posts
    3

    Thanks!

    SELECT name,CAST(xmlFields as varchar(8000)) as xmlFields, MAX(accountId)
    FROM tblQueries
    GROUP BY name, CAST(xmlFields as varchar(8000))

Tags for this Thread

Posting Permissions

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