We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

How to write this access query in MS SQL

ubsmail
ubsmail asked
on
Medium Priority
239 Views
Last Modified: 2012-06-27
How can I write this query to do the same function in SQL

Select

CatIDs.GoogleTax1 + IIf(IsNull(GoogleTax2) or GoogleTax2='','',' > '+GoogleTax2) + IIf(IsNull(GoogleTax3) or GoogleTax3='','',' > '+GoogleTax3) + IIf(IsNull(GoogleTax4) or GoogleTax4='','',' > '+GoogleTax4) + IIf(IsNull(GoogleTax5) or GoogleTax5='','',' > '+GoogleTax5) + IIf(IsNull(GoogleTax6) or GoogleTax6='','',' > '+GoogleTax6) as GoogleTax

from products
 
Comment
Watch Question

Aaron TomoskyDirector, SD-WAN Solutions
CERTIFIED EXPERT

Commented:
As I'm on my phone I'm not going to type a working version but here is an outline.  Basically use case instead of iff
Select (googletax1
case when googletax2 is null then '' else +', '+googletax2 endcase
Snr. Development Manager
CERTIFIED EXPERT
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Alpesh PatelSolution Architect at TCS (SAFe®Agilist, TOGAF® Foundation, PSM I®, MCP, MCSD)
CERTIFIED EXPERT

Commented:
Select

CatIDs.GoogleTax1 + (case when GoogleTax2 is null or GoogleTax2='' then '' else ' > ' end) +GoogleTax2)

Author

Commented:
Thanks all
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.