Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Error msg

Author  Topic 

phong919
Starting Member

29 Posts

Posted - 2008-08-07 : 11:21:38
Hello all,

I get the following error message when i do a group by. Can someone explain to me what the error means? Thank you.

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

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-08-07 : 11:24:58
You can't do GROUP BY over TEXT or NTEXT columns.



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

phong919
Starting Member

29 Posts

Posted - 2008-08-07 : 11:32:54
is there another way for me to return 1 row of data base on what the user has selected?
Go to Top of Page

Transact Charlie
Master Smack Fu Yak Hacker

3451 Posts

Posted - 2008-08-07 : 11:34:17
Depends on whether you need that text field and which sql server you are using.

I think on 2005 you can cast to VARCHAR(MAX) (or NVARCHAR(MAX)) and group by that.


-------------
Charlie
Go to Top of Page

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2008-08-07 : 11:41:42
A common mistake that "new to sql server"s make is to define columns as text or ntext where the column content will never excede 8000 characters (or 4000 for unicode). If that is the case you should consider altering the columns to char, varchar, nchar, or nvarchar.

Be One with the Optimizer
TG
Go to Top of Page

phong919
Starting Member

29 Posts

Posted - 2008-08-07 : 12:02:12
I do need that text field, and i'm using sql 2005. How would i do a cast for that column?
Go to Top of Page

phong919
Starting Member

29 Posts

Posted - 2008-08-07 : 12:06:59
i just used a convert to varchar and it worked. Thank you for all input. is that the correct way of doing it?
Go to Top of Page

jezemine
Master Smack Fu Yak Hacker

2886 Posts

Posted - 2008-08-07 : 12:17:21
if you are on 2005, you shouldn't be using text, ntext, or image columns at all - they are deprecated in 2005.

prefer instead varchar(msx), nvarchar(max), varbinary(max)


elsasoft.org
Go to Top of Page
   

- Advertisement -