select c.[Name] DCommType,si.*
from t_event_spontaneityInfo si
 left join t_code_public c on si.commtype = c.Code and c.typecode = '05'
left join t_event_spontaneityOppose so on si.rid = so.SpontaneityInfoRID, 
( select w.rid watchrid 
from t_base_dept d ,t_base_watchfix w 
where d.rid = w.rdeptrid and d.ParentLayNo = '000001001' ) f 
where so.sponwatchfixrid = f.watchrid and so.domaintype = '41' and si.SponTime>='2008-9-3 0:00:00' and si.SponTime<='2008-9-10 23:59:59'
select distinct c.[Name] DCommType,si.* 
这样写是会报错的
:
不能以 DISTINCT 方式选择 text、ntext 或 image 数据类型。 

解决方案 »

  1.   

    用convert把text、ntext 或 image转换下
      

  2.   

    既然如此,那就把除了text,ntext,image以外的列用distinct取出来,再与其他列连接查询.
      

  3.   

    text数据类型不能用DISTINCT,也不能用GROUP BY 分组,这和它的内部数据存储有关
    因此,如果可以,你先转换成VARCHAR在DISTINCT
      

  4.   

    没见过谁要去DISTINCT TEXT这样大文本字段的,你的设计和需求有问题.
      

  5.   

    把ntext或text字段转换成varchar(max),image类型就没办法了,你的设计可能有点问题哈,不建议对这几种类型distinct
      

  6.   


    用convert把text、ntext 或 image转换为nvarchar(8000),具体好像忘记,也有可能是4000,你查一下。,
      

  7.   

    比较ugly的方法:写两遍,用union试试,自己没试过,你看看行不行