?
Solved

UNION for text datatype

Posted on 2003-12-10
3
Medium Priority
?
773 Views
Last Modified: 2012-08-14
how to join(UNION) 2 tables  having a column of dataType 'TEXT'

it is giving error
" text,ntext,image can not be selected as distinct "
0
Comment
Question by:singhhome
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
3 Comments
 
LVL 26

Expert Comment

by:Hilaire
ID: 9911202
Hi,

You could use UNION ALL instead (no distinct performed, but you have to be sure that the two queries union-ed are logically exclusive or you'll get duplicates

Hilaire
0
 
LVL 26

Expert Comment

by:Hilaire
ID: 9911216
if union all is not an option,
you'll have to convert the text fields to varchar(8000) in the select statement

the bad thing is that it will truncate text that would be more than 8000 cars long

Note: max length for varchar must be lower than 8000 if you have SQL 7

Hilaire
0
 
LVL 26

Accepted Solution

by:
Hilaire earned 200 total points
ID: 9911376
The difference between UNION and UNION ALL
is that UNION tries to remove duplicates, UNION ALL doesn't

UNION is logically equivalent to select distinct on UNION ALL

That's why you get this error message

Both are equivalent if the two queries are logically exclusive
(if their intersection is null)

Hilaire
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Viewers will learn how the fundamental information of how to create a table.
Suggested Courses

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question