Avatar of Software Engineer
Software Engineer
 asked on

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

Hi:

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?

Thanks!

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%'

Open in new window

SQL* T-SQLMicrosoft SQL Server

Avatar of undefined
Last Comment
Scott Pletcher

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Arana (G.P.)

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Scott Pletcher

Quite correct overall, but you should use VARCHAR(8000) in the first version, not 4000.
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck