Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Help with SQL CASE SELECT

Posted on 2010-11-30
2
Medium Priority
?
260 Views
Last Modified: 2012-05-10
See my code below.. I want the code to put the field sComment to stated below if the berrorflag is 0 otherwise I want the sComment to have something else.. The second "case" keword is highlighted and I'm not sure what I'm doing wrong
CASE 
	WHEN  css.bErrFlag =0
     CASE (css.sDeliveryMethod)
	  WHEN 'fax'    THEN 'Web customer requests the listed invoice number: ' + (css.sTransactionNo) + ' to be sent via: ' 
		    + (css.sDeliveryMethod) + ' to ' + COALESCE(css.sPhone_Fax, '') 
	  WHEN 'email'  THEN 'Web customer requests the listed invoice number: ' +  (css.sTransactionNo) + ' to be sent via: ' 
		    + (css.sDeliveryMethod) + ' to ' + COALESCE(css.semail, '') 
	  WHEN 'e-mail' THEN 'Web customer requests the listed invoice number: ' + (css.sTransactionNo) + ' to be sent via: ' 
		    + (css.sDeliveryMethod) + ' to ' + COALESCE(css.semail, '') 
	  WHEN 'mail'   THEN 'Web customer requests the listed invoice number:  ' +  (css.sTransactionNo) + ' to be sent via: ' 
		    + (css.sDeliveryMethod) + ' to ' + COALESCE(css.saddress1, '') + '; ' + COALESCE(css.sAddress2, '') 
		    + '; ' + COALESCE(css.scity, '') + ', ' + COALESCE(css.sstate, '') + '  ' + COALESCE((right(css.szip,5)), '') 
     ELSE 'Customer requested invoices be sent and did not choose a delivery method. '
     END 
  ELSE 'Error in case:'+(css.sErrMsg)
  END sComment,

Open in new window

0
Comment
Question by:cheryl9063
2 Comments
 
LVL 32

Accepted Solution

by:
Erick37 earned 2000 total points
ID: 34239579
You need a THEN after the first CASE:

CASE WHEN  css.bErrFlag =0 THEN
0
 
LVL 1

Author Closing Comment

by:cheryl9063
ID: 34239589
Perfect thanks so much!!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Recursive SQL is one of the most fascinating and powerful and yet dangerous feature offered in many modern databases today using a Common Table Expression (CTE) first introduced in the ANSI SQL 99 standard. The first implementations of CTE began ap…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question