Need help with using the UNION to union two SELECT statements

I have the two SELECT statements that work great when executed alone. I need to union them so I have the 2 results combined and returned as 1. When I use UNION for the 2 SELECTS, I get the follow error:

Msg 207, Level 16, State 3, Line 1
Invalid column name 'tBirthDate'.
Msg 207, Level 16, State 3, Line 1
Invalid column name 'tBirthDate'.

Here is the complete statements

Select cType as Type,
cDesc as Description,
CONVERT(varchar(2),
MONTH(dtEvent)) + ' - ' + CONVERT(varchar(2), DAY(dtEvent)) as Date,
month(dtEvent) as Month
from dbo.Events
union
SELECT 'Birthday' as Type,
ISNULL(cNickName, cFirstName) + ' ' + ISNULL(cLastName, '') + ' ' + ISNULL(cSuffix, '') AS Description,
CONVERT(varchar(2),
MONTH(tBirthDate)) + ' - ' + CONVERT(varchar(2), DAY(tBirthDate)) AS Date,
month(tBirthDate) as Month
FROM         dbo.PEOPLE
WHERE     (MONTH(tBirthDate) = month(getdate()) OR
MONTH(tBirthDate) = (month(getdate())+1)) AND (bHideBirthdate = 0) AND (nStatusUID = 75)
ORDER BY MONTH(tBirthDate), DAY(tBirthDate)

Can you help me with this getting it working?
gtrappAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

chapmandewCommented:
Does the tBirthDate column exist in the People table?
0
Guy Hengel [angelIII / a3]Billing EngineerCommented:
this will work:
Select cType as Type, 
cDesc as Description, 
REPLACE(CONVERT(varchar(5), dtEvent, 1 ), '/', '-') as [Date], 
month(dtEvent) as Month 
from dbo.Events
union all
SELECT 'Birthday' as Type, 
ISNULL(cNickName, cFirstName) + ' ' + ISNULL(cLastName, '') + ' ' + ISNULL(cSuffix, '') AS Description, 
REPLACE(CONVERT(varchar(5), tBirthDate, 1 ), '/', '-') as [Date], 
month(tBirthDate) as Month
FROM         dbo.PEOPLE
WHERE     (MONTH(tBirthDate) = month(getdate()) OR
MONTH(tBirthDate) = (month(getdate())+1)) AND (bHideBirthdate = 0) AND (nStatusUID = 75)
ORDER BY  3

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
gtrappAuthor Commented:
Yes.

I am thinking that it could be data type of the column. Having two different data types will not make the UNION work.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2005

From novice to tech pro — start learning today.

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.