T-SQL Tutorials - TSQLTutorials.com

UNION - Join Data Sets


Introduction

The UNION keyword in TSQL is used to combine two datasets. The two datasets must have the same number of columns in them and use the same datatypes. The datasets must also have the columns in the same comparative order. The UNION T-SQL Expression places the UNION keyword between two datasets. By using the UNION keyword between two datasets, TSQL will return a new dataset that contains what is in the first dataset and also what is in the second dataset. All the records in the new dataset that is created using the UNION keyword, will be distinct. That means that if there are multiple records in datasets that have exactly the same values, the resulting dataset will only contain one those records with those values. The UNION keyword is often used in this fashion:

  • SELECT col1,col2,coln... FROM table1 '[DataSet #1]
  • UNION
  • SELECT col1,col2,coln... FROM table2 '[DataSet #2]


Microsoft SQL Server 2014 Standard Edition Server w/20 CAL’s

Price: $641.99
Buy It Now
SQL Server 2014 Standard Edition, 32bit & 64bit, Media & License w/25CAL

Price: $549.99
Buy It Now
MSFT SQL Server 2016 Standard Edition x64 64bit | Full Edition |Original| 25CAL

Price: $999.99
Buy It Now
MSFT SQL Server 2016 Standard Edition x64 64bit | Full Editon | Original | 10CAL

Price: $549.99
Buy It Now
MSFT SQL Server 2008 R2 Enterprise Edition 25 CAL 32/64-Bit

Price: $299.99
Buy It Now
MSFT SQL Server 2008 R2 Standard Edition 32/64-Bit 10 CAL Edition

Price: $224.99
Buy It Now







Copyright 2017 - TSQLTutorials.com