我有两个表,其属性如下date(datetime),headline(varchar),text(text)
现在我想联合所有这两个表并按日期时间排序。执行此操作时出现错误:
工作表中只允许使用文本指针,不允许使用 text、ntext 或 image 列。查询处理器生成了一个查询计划,该计划需要工作表中的 text、ntext 或 image 列。
来回尝试后,我发现是导致错误的文本属性。但是该怎么办?我尝试转换为 VARCHAR 没有成功。两个表都在文本属性中使用文本格式。
此外,当删除 ORDER BY 时,一切正常。该怎么办?
下面是原始的 SQL 查询,但您可以只回复上面的简化。
SELECT id, datetime, author, headline, intro, text, type, toppriority,
secondpriority, comments, companyid, '1' source
FROM Table1
UNION ALL
SELECT AutoID AS id, Dato AS datetime,
ID COLLATE SQL_Latin1_General_CP1_CI_AS AS author, NULL AS headline,
NULL AS intro, Notat COLLATE SQL_Latin1_General_CP1_CI_AS AS text,
CAST(NotatTypeID AS VARCHAR) AS type,
NULL AS toppriority, NULL AS secondpriority, NULL AS comments,
Selskabsnummer AS companyid, '2' source
FROM Table2
WHERE (NotatTypeID = '5') OR (NotatTypeID = '6')
ORDER BY datetime DESC
提前致谢