March 28, 2006 at 6:03 pm
How to include a ntext column in the group by clause?
Example comments is a ntext column
select comments from tablename group by comments
is giving a error message as
The text, ntext, and image data types cannot be compared or sorted, except when using IS NULL or LIKE operator.
March 31, 2006 at 8:00 am
This was removed by the editor as SPAM
April 3, 2006 at 5:41 pm
Hi,
I have tried with the below example...
create table abc (a ntext)
insert into abc values ('badbadabdada')
select convert(nvarchar,a),count(*) from abc group by convert(nvarchar,a)
and this works!!
Regards,
Indra Narayan.
April 3, 2006 at 8:57 pm
Use caution here, you are not actually grouping by the entire ntext column, only the first 30 character!
Aunt Kathi Data Platform MVP
Author of Expert T-SQL Window Functions
Simple-Talk Editor
April 6, 2006 at 11:26 pm
Thanks for your reply.
I found if we query a ntext column, it does not result in full text, it cuts off in the middle.
I understand if we assign it to a variable in an sp and then query, it would then give the full result.
But I want to get the result by doing a select query as I am writing a view.
April 7, 2006 at 10:03 am
Are you on SQL Server 2005? If so, try converting the ntext column to
nvarchar(MAX). Or, better yet, change the actual column to nvarchar(MAX) if you can.
Aunt Kathi Data Platform MVP
Author of Expert T-SQL Window Functions
Simple-Talk Editor
April 12, 2006 at 12:04 am
I am using sqlserver 2000.
I cant change the actual column, so I have to work on the query only.
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply