Link to home
Start Free TrialLog in
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

ASKER CERTIFIED SOLUTION
Avatar of Arana (G.P.)
Arana (G.P.)

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Quite correct overall, but you should use VARCHAR(8000) in the first version, not 4000.