Solved

UNION for text datatype

Posted on 2003-12-10
3
765 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
  • 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 50 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

Edgartown IT Case Study

Learn about Edgartown's quest to ensure the safety and security of the entire town's employee and citizen data. Read the case study!

Question has a verified solution.

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

The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
I have a large data set and a SSIS package. How can I load this file in multi threading?
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

733 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