Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

UNION for text datatype

Posted on 2003-12-10
3
Medium Priority
?
776 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

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

Question has a verified solution.

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

In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Via a live example, show how to shrink a transaction log file down to a reasonable size.

610 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