Hi,
Im having two tables with attributes like date(datetime),headline(varchar),text(text)
Now i want to UNION ALL these two tables and sort by the datetime. When doing this i'm getting the error:
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.
After trying back and forth i found out that it is the text attribute which is causing the error. But what to do? I tried casting to VARCHAR with no succes. Both tables uses text format in the text attribute.
Also when removing the ORDER BY it all works fine. What to do?
The original SQL query is below, but you can just reply to the simplified above.
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
Thanks in advance