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 数据类型。
因此,如果可以,你先转换成VARCHAR在DISTINCT
用convert把text、ntext 或 image转换为nvarchar(8000),具体好像忘记,也有可能是4000,你查一下。,