You should list the columns you need in your SELECT query and you can change the column which is text data type in your query with a CAST function to varchar(max)(or nvarchar(max) if your column is ntext).
Here is an example:
SELECT DISTINCT col1, CAST(textCol as varchar(max)) as textCol, col3 FROM yourtable
limno
All-Star
117314 Points
7997 Posts
Moderator
MVP
Re: The text data type can not be selected as DISTINCT because it is not comparable.
Feb 28, 2012 02:06 PM|LINK
You should list the columns you need in your SELECT query and you can change the column which is text data type in your query with a CAST function to varchar(max)(or nvarchar(max) if your column is ntext).
Here is an example:
SELECT DISTINCT col1, CAST(textCol as varchar(max)) as textCol, col3 FROM yourtable
Format your SQL query with instant sql formatter:
http://www.dpriver.com/pp/sqlformat.htm