• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 748
  • Last Modified:

T-SQL: Remove Duplicates in Select statements with ntext data type

Hi experts,

  I'm writing a select statments witht ntext data type field.  This select statment requires a Union operator.  Since Sql Server 2005 gave me an error "The ntext data type cannot be selected as DISTINCT because it is not comparable", I have to change Union to Union All.  When Union All is used, the statment works without error.  However, it returns duplicate rows.  

  How do I eliminate these the duplicated rows from the select statment?


Thank you!!!  
0
cuconsortium
Asked:
cuconsortium
1 Solution
 
cmgarnettCommented:
Have you tried casting your ntext values to varchar. This is possible if the first x thousand records will do what you need of them.

SELECT CAST (myColumn AS VARCHAR(8000)),......

0
 
cuconsortiumAuthor Commented:
It works! Great!
0
 
dqmqCommented:
Or batter yet, cast (mycolumn as nvarchar(max)), which has no such limitations
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now