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
34 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
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 
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.

Question has a verified solution.

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

Suggested Solutions

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 …
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

816 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

11 Experts available now in Live!

Get 1:1 Help Now