Unix Technical Forum

Group by on the text colum throws error

This is a discussion on Group by on the text colum throws error within the SQL Server forums, part of the Microsoft SQL Server category; --> Hi , I have this query paprojnumber is varchar patx500 is text palineitemseq is int select Paprojnumber,Patx500,max(palineitemseq) from pa02101,pa01601 ...


Go Back   Unix Technical Forum > Database Server Software > Microsoft SQL Server > SQL Server

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-29-2008, 05:24 AM
AJ
 
Posts: n/a
Default Group by on the text colum throws error

Hi ,

I have this query

paprojnumber is varchar
patx500 is text
palineitemseq is int

select Paprojnumber,Patx500,max(palineitemseq) from pa02101,pa01601
where
pa02101.pabillnoteidx=pa01601.pabillnoteidx group by
paprojnumber,patx500

it throws this error
Server: Msg 306, Level 16, State 2, Line 1
The text, ntext, and image data types cannot be compared or sorted,
except when using IS NULL or LIKE operator.

Thanks a lot for your help.

AJ
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-29-2008, 05:24 AM
Robin Tucker
 
Posts: n/a
Default Re: Group by on the text colum throws error

Here it means exactly what the error says. You cannot sort on a text field
(or NText field), which is what your "group by" code is trying to do.

"AJ" <aj70000@hotmail.com> wrote in message
news:6097f505.0409300838.a81c800@posting.google.co m...
> Hi ,
>
> I have this query
>
> paprojnumber is varchar
> patx500 is text
> palineitemseq is int
>
> select Paprojnumber,Patx500,max(palineitemseq) from pa02101,pa01601
> where
> pa02101.pabillnoteidx=pa01601.pabillnoteidx group by
> paprojnumber,patx500
>
> it throws this error
> Server: Msg 306, Level 16, State 2, Line 1
> The text, ntext, and image data types cannot be compared or sorted,
> except when using IS NULL or LIKE operator.
>
> Thanks a lot for your help.
>
> AJ



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-29-2008, 05:25 AM
Ross Presser
 
Posts: n/a
Default Re: Group by on the text colum throws error

On Thu, 30 Sep 2004 18:24:58 +0100, Robin Tucker wrote:

> Here it means exactly what the error says. You cannot sort on a text field
> (or NText field), which is what your "group by" code is trying to do.


You can, however, group by an expression using it:

select Paprojnumber,Patx500,max(palineitemseq)
from pa02101,pa01601
where pa02101.pabillnoteidx=pa01601.pabillnoteidx
group by paprojnumber,convert(varchar(50),patx500)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 08:45 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com