what is differece between union and union all

Answers were Sorted based on User's Feedback



what is differece between union and union all..

Answer / samy

Union:
combine two tables and common values to be retrieved no
duplicate values

Union All:

All the values to be retrieved when combine two table.
(duplicate values)

Is This Answer Correct ?    10 Yes 1 No

what is differece between union and union all..

Answer / shyam

Union: It will combine the output of two or more queries &
it will eliminate duplicate values.

Union all:It will combine the output of two or more queries
& it will not eliminate duplicate values.

Is This Answer Correct ?    6 Yes 0 No

what is differece between union and union all..

Answer / ramesh raja

UNION: combine distinct values between two tables
UNION ALL : combine all values and also duplicates values
between the two tables

Is This Answer Correct ?    4 Yes 0 No

what is differece between union and union all..

Answer / dinesh sharma

Union:Only Select Distinct Value
Union All:Select All Values Using Duplicate
All Selected Columns Must Have Same DataType
Example:
Table 1 : First,Second,Third,Fourth,Fifth
Table 2 : First,Second,Fifth,Sixth

Is This Answer Correct ?    1 Yes 0 No

what is differece between union and union all..

Answer / shabanafazal

in case of 'union' the data of two tables are combined
together with no repetition where as incase of 'union all'
repetition of data is done e.g in table 'A' we have name
saad three times and in 'B' table name 'ssad' is present
one time then in case of 'union' 'saad' is appeard once
(when union of table 'A' and 'B' is done). where as in case
of 'union all' the name 'saad' will repeated four times.

Is This Answer Correct ?    1 Yes 0 No

what is differece between union and union all..

Answer / dinesh waitage

1)Union is used to select distinct values from two tables
where as union all is used to select all values including
duplicates from the tables.

2)UNION - returns on Distinct rows/Slower in performance
UNION ALL.

Is This Answer Correct ?    1 Yes 0 No

Post New Answer

More SQL Server Interview Questions

how to update a null value field in sql server eg a table contains 3 fields id,name,salary and 3 records salary of 1 record is null i want update the nullfield 111 arun 300 112 ddd 200 113 ttt null i want to update table with add 100 to every record include null after updation the recrds should be 111 arun 400 112 ddd 300 113 ttt 100

6 Answers   ABC, HCL,


How to find the second largest salary in the emp database and also How to find 3rd,4th and so on ........ in the emp database plz mail the answer @ mak2786@gmail.com

35 Answers   Oracle, Scend, TechInfini,


What is the difference between a stored procedure and a user defined function in sql server?

2 Answers   Millennium,


What are date and time data types in ms sql server?

0 Answers  


Give main differences between "Truncate" and "Delete".

0 Answers   HCL,






What is the difference between UNIQUE and DISTINCT keywords in DBMS?

1 Answers   Genpact,


How ssrs maintain security?

0 Answers  


What is SubQuery in SQL Server 2008

0 Answers   HCL,


How to enable/disable indexes?

0 Answers  


What are the steps you will take to improve the performance of a poor performing query?

0 Answers  


Explain atomicity?

0 Answers  


What is the security model used in sql server 2005?

0 Answers  


Categories