Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

sql server 2005 union  query where tables have some different columns

Posted on 2011-09-02
3
Medium Priority
?
599 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Composite queries are used to retrieve the results from joining multiple queries after applying any filters. UNION, INTERSECT, MINUS, and UNION ALL are some of the operators used to get certain desired results.​
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

609 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