Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3212794
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T14:52:30+00:00 2026-05-17T14:52:30+00:00

Im having two tables with attributes like date(datetime),headline(varchar),text(text) Now i want to UNION ALL

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T14:52:31+00:00Added an answer on May 17, 2026 at 2:52 pm

    One way round this is to run the union as a sup query and order the results afterwards:

    SELECT * FROM 
    (
        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')
    ) a
    ORDER BY datetime DESC
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How do you select all fields of two joined tables, without having conflicts with
I am having two tables like this.Both are separate tables AccountNo User Name ----------------------------------
I am having two tables Room_master and Room_Item Room_Master => roomid - pk, roomname
I'm having the following two tables... Table : room_type type_id type_name no_of_rooms max_guests rate
I have two tables in my database schema that represent an entity having a
Im having some trouble with joining two tables. This is what my two tables
So i'm having this problem. I have two tables (Oracle), one is called Destination
I'm having some problems trying to perform a query. I have two tables, one
In MySQL Im having two tables: PRODUCTS (id, Name) SEEALSO (id, prodLeft, prodRight) SEEALSO
i'm having to two tables, which i need to compare both the table. Let

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.