Solved

UNION for text datatype

Posted on 2003-12-10
3
762 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
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…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

789 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