当前位置: 代码迷 >> DB2 >> SQL 一个UNION ALL 的排序有关问题
  详细解决方案

SQL 一个UNION ALL 的排序有关问题

热度:4008   发布时间:2013-02-26 00:00:00.0
SQL 一个UNION ALL 的排序问题
Select id, resultId, remark, inputDate, type From (
SELECT id, resultId, remark, inputDate, type = 'TelephoneSectionRecord' FROM TelephoneSectionRecord WHERE userId = 'ST_0000001' AND clientId = 'ST_0000001_RS_000005' 
union all 
SELECT id, activityId, resultId, inputDate, type = 'Schedule' FROM Schedule WHERE userId = 'ST_0000001' AND clientId = 'ST_0000001_RS_000005' AND inputDate <= '2009/3/16' 
union all 
SELECT id, mailTitle, mailContent, updateTimeStamp as inputDate, type = 'SentEmail' FROM EMailSentRecord WHERE addressee LIKE '%danielwong@uth.com.hk%') 
DERIVEDTBL ORDER BY inputDate DESC

提示

Microsoft OLE DB Provider for SQL Server ???~ '80040e14' 

Only text pointers are allowed in work tables, never text, ntext, or image columns. The query processor produced a query plan that required a text, ntext, or image column in a work table. 

如果去掉排序就运行没有问题.请高手告诉解决方案.


------解决方案--------------------------------------------------------
你哪列是text啊,改成varchar不行吗?