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
 Distinct problem

Author  Topic 

boreddy
Posting Yak Master

172 Posts

Posted - 2008-07-31 : 00:54:51
I am getting this message when i applied distinct
in my query. i am having one text datatype column,
is not applicable distinct for text datatypes

Msg 421, Level 16, State 1, Line 1
The text data type cannot be selected as DISTINCT because it is not comparable.

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2008-07-31 : 00:57:24
you can not use DISTINCT with text data type.

use convert() to convert the text column to varchar first


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

boreddy
Posting Yak Master

172 Posts

Posted - 2008-07-31 : 01:04:45
we can use distinct to text na
why i am getting that error pls clarify
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2008-07-31 : 01:13:21
quote:
Originally posted by boreddy

we can use distinct to text na
why i am getting that error pls clarify



what do you mean ?


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

boreddy
Posting Yak Master

172 Posts

Posted - 2008-07-31 : 01:25:10
with out converting the text column to varchar we cant get the distinct result
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2008-07-31 : 01:28:47
quote:
Originally posted by boreddy

with out converting the text column to varchar we cant get the distinct result



Yes. that's correct. You CANNOT USE distinct on column with TEXT data type.


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-07-31 : 05:24:27
quote:
Originally posted by boreddy

with out converting the text column to varchar we cant get the distinct result


if you're using sql 2005 use BLOB datatypes like varchar(max),nvarchar(max),.. in place of text & ntext
Go to Top of Page
   

- Advertisement -