Is there any way to DISTINCT or group by a text (or ntext) in SQL Server 2005?

前端 未结 4 1143
难免孤独
难免孤独 2020-12-10 23:49

In a table, I have a column called MEMO_TEXT that is a text data type. When I try creating a view and use a GROUP BY, I get the following error:

SQL S

4条回答
  •  佛祖请我去吃肉
    2020-12-11 00:38

    Do you know that there will never be repeated data in the ntext field? You could do the distinct in a derived table on the other fields and then join to the table with the ntext field and grab it in the outer query.

    something like (assume field3 is the ntext field)

    select mt.idfield, a.field1, a.field2, mt.field3 
    from mytable mt
    join 
    (select disitinct mt1.idfield, mt1.field1, mot.field2 from mytable mt1
    join myothertable mot on mt1.idfield = mot.idfield) a 
       on a.ifield = mt.idfield
    

提交回复
热议问题