Solved

Is there a work for getting the unique values from 2 tables and putting them into another table?

Posted on 2016-10-13
7
24 Views
Last Modified: 2016-10-13
Is there a work for getting the unique values from 2 tables and putting them into another table?
0
Comment
Question by:zimmer9
  • 4
  • 3
7 Comments
 
LVL 65

Expert Comment

by:Jim Horn
ID: 41842715
Yes, there is 'a work'.  To demonstrate how to pull that off you'll need to give us 'a data mockup' of both source and destination tables, with a description of what values you're trying to pull.
0
 

Author Comment

by:zimmer9
ID: 41842719
Sorry, I meant "word".
0
 

Author Comment

by:zimmer9
ID: 41842727
as in a word that signifies pulling in the unique values from 2 tables into 1 universal table of unique values.
0
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
LVL 65

Expert Comment

by:Jim Horn
ID: 41842732
Still not sure what the heck you're asking us, so a data mockup would really work well here.

Let me know if this is what you were thinking:  Table Based Access Variables
0
 

Author Comment

by:zimmer9
ID: 41842769
My question is purely one of terminology.

Let's say I have 2 tables comprised of Holidays for different companies as follows:

For example:

table A:              table B:

values                values

Jan  2                  Jan  2
Jan 16                Jan  16
Feb 20               Feb 20
Apr 14    
May 29              May 29
Jul  4                  Jul 4
Sep  4                Sep 4
Oct  9          
                           Nov 11
Nov 23              Nov 23
Dec 25              Dec 25


And I wanted to create another table comprised of the distinct values contained in the 2 tables, is there a terminology for this process. If there isn't, then we can close this question.  :)  

I'm not asking for a SQL statement, just a phrase if I were writing a specification.
0
 
LVL 65

Accepted Solution

by:
Jim Horn earned 500 total points
ID: 41842777
Since you're asking this question in the SQL Server zone, I'll use that terminology and call this 'UNION all distinct values in two tables'.  Other experts may have slightly different terminology.

SELECT DISTINCT day
FROM (
   SELECT day FROM TableA
   UNION 
   SELECT day FROM TableB) 
WHERE COALESCE(day, '') <> ''

Open in new window


I know you didn't want a SQL statement, but since you're asking we might as well ask that terminology, just to make sure a developer does not mis-understand the requirements.
0
 
LVL 65

Expert Comment

by:Jim Horn
ID: 41842800
Thanks for the grade.  Good luck with your project.
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Join & Write a Comment

I wrote this interesting script that really help me find jobs or procedures when working in a huge environment. I could I have written it as a Procedure but then I would have to have it on each machine or have a link to a server-related search that …
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…
Via a live example, show how to setup several different housekeeping processes for a SQL Server.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

760 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now