[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 604
  • Last Modified:

sql server 2005 union query where tables have some different columns

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
blossompark
Asked:
blossompark
2 Solutions
 
LimbeckCommented:
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
 
Kakhaber SiradzeCommented:

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
 
blossomparkAuthor Commented:
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now