?
Solved

sql server 2005 union  query where tables have some different columns

Posted on 2011-09-02
3
Medium Priority
?
598 Views
Last Modified: 2012-06-22
I need to do  a union of two tables which have common columns but also have some different columns.
 union
any help appreciated...thanks
0
Comment
Question by:blossompark
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 19

Assisted Solution

by:Limbeck
Limbeck earned 400 total points
ID: 36472039
try a full outer join on first name and last name. but since it feels like im doing your homework thats all im gonna say ;)
0
 
LVL 5

Accepted Solution

by:
Angelgeo earned 1600 total points
ID: 36472073

select
  [first name],
  [Last Name],
  [dept],
  [Service],
  null as age
from tableA
union all
select
  [first name],
  [Last Name],
  null as [dept],
  null as[Service],
  [age]
from tableB

Open in new window

0
 

Author Closing Comment

by:blossompark
ID: 36472094
Hi Limbec,
thanks for your input....not homework...just under a lot of pressure here to produce something and hard to think straight...

Hi Angelgeo,
thanks for that, saw something similar on google but was using NULL only as a column name  and didnt work...so I'll put in the "AS" and i'm sure it will be fine...
thanks again...
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

by Mark Wills Attending one of Rob Farley's seminars the other day, I heard the phrase "The Accidental DBA" and fell in love with it. It got me thinking about the plight of the newcomer to SQL Server...  So if you are the accidental DBA, or, simp…
Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

765 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