:::: MENU ::::

Using NULL in UNION clause of T-SQL

  • Oct 15 / 2008
  • 0
dbDigger, Null Values, T-SQL Tips and Tricks

Using NULL in UNION clause of T-SQL

Question: What is the output of the following query?

 
SELECT 1  
 UNION  
 SELECT NULL  
 UNION  
 SELECT '1'  

Answer: NULL, 1

Explanation: UNION only takes distinct values and ‘1’ is implicitly converted to 1. So the NULL comes first and then 1 comes.

Ref: Union –

Note: The Question of day is taken from SQLServercentral.com. I want to compile selected QOD.

Consult us to explore the Databases. Contact us