user10665108
user10665108

Reputation:

How make a Distinct correct?

i would like make a Distinct correct for this query in SQL server 2014

select DISTINCT IntrnalKey,   CatName, QName, QString 
from OUQR inner join
     OQCN
     on QCategory = CategoryId

i had the error - Msg 421, Level 16, State 1, Line 3 The ntext data type cannot be selected as DISTINCT because it is not comparable.

is there is better ways please help me

Upvotes: 1

Views: 120

Answers (1)

Andy
Andy

Reputation: 3170

To use an ntext column in SELECT DISTINCT you need to first cast it to another data type. My go-to is SELECT DISTINCT CAST(Field AS NVARCHAR(MAX).

Upvotes: 1

Related Questions