Advertisement
jchaven

How to select DISTINCT values on TEXT columns

Nov 29th, 2014
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
T-SQL 0.35 KB | None | 0 0
  1. -- To avoid error: "The text data type cannot be selected as DISTINCT because it is not comparable."
  2.  
  3. -- list all descriptions (and duplicates) (TEXT datatype)
  4. SELECT original_desc FROM Report..A0004_01;
  5.  
  6. -- list all descriptions (without duplicates) (convert TEXT datatype)
  7. SELECT DISTINCT CONVERT(VARCHAR(MAX), original_desc) FROM Report..A0004_01;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement