convert small query from access to SQL Server

Sorry for the simple question, but i have a small query that is in access and I need to convert it so that it works in SQL server

the code is
IIf(Nz([SumofAmount])+Nz([LegacyTotal])=0,Null,CCur(Nz([SumofAmount])+Nz([LegacyTotal]))) AS AllLegacyTotal

Open in new window

thanks in advance,
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.

Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
give this a whirl..
   WHEN COALESCE(SumofAmount,0) + COALESCE(LegacyTotal,0) <> 0 
      THEN CAST(COALESCE(SumofAmount,0) + COALESCE(LegacyTotal,0) as money)
   ELSE NULL END as AllLegacyTotal 

Open in new window


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
damixaAuthor Commented:
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
Thanks for the grade.  Good luck with your project.  -Jim
I've seen 2 questions like this now...

IIF translates to a "case expression"
Nz translates to ISNULL() or COALESCE() (the later accepts more parameters than isnull )
CCur translates to CAST() or CONVERT() using the 'money' as type

CASE (Transact-SQL)
CAST and CONVERT (Transact-SQL)

IIF ( boolean_expression, true_value, false_value )
is available in SQL 2012
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 2008

From novice to tech pro — start learning today.