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
blossomparkAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
Kakhaber SiradzeConnect With a Mentor Commented:

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
 
LimbeckConnect With a Mentor Commented:
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
 
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.