troubleshooting Question

T-SQL: The text data type cannot be selected as DISTINCT because it is not comparable

Avatar of Software Engineer
Software Engineer asked on
SQL* T-SQLMicrosoft SQL Server
2 Comments1 Solution74 ViewsLast Modified:

Below is my code and the error message that I'm getting with using DISTINCT.

Besides using varchar(MAX), which isn't working, what else can be done in the syntax to allow for DISTINCT?


Software Engineer

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

select DISTINCT SOP30200.CUSTNMBR, sy01200.EmailToAddress
FROM sop30200 left outer join sy01200 on sop30200.CUSTNMBR = sy01200.Master_ID
where Master_ID like 'AAR%'
Arana (G.P.)

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 2 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros