Please start any new threads on our new site at http://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Site Related Forums
 Article Discussion
 CASE Question
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

IHaveNoClue
Starting Member

USA
2 Posts

Posted - 02/10/2003 :  15:16:53  Show Profile  Reply with Quote
How do you use CASE to affect values outside the clause?

Example:
SELECT
tblClientMaster.sName AS 'ClientName',
Case InvoiceTransactionType.sName
WHEN 'Void' Then
VoidReason.sName = " ",
VoidReason.sDescription = " ",
VoidReason.iSort = " "
Else
VoidReason.sName AS VoidReasonName,
VoidReason.sDescription AS VoidReasonDescription,
VoidReason.iSort AS VoidReasonNumber
End

Any ideas?

jsmith8858
Dr. Cross Join

USA
7423 Posts

Posted - 02/10/2003 :  16:13:17  Show Profile  Visit jsmith8858's Homepage  Reply with Quote
you need to repeat the CASE expression 3 times.

SELECT
tblClientMaster.sName AS 'ClientName',
Case sName WHEN 'Void' THEN " " ELSE sName END as sName,
CASE sName WHEN 'Void' THEN " " ELSE sDescription END as sDescription,
CASE sName WHEN 'Void' THEN " " ELSE iSort END as iSort
FROM
...

Also, note that naming fields with prefixes based on their datatype isn't really the "hip" thing to do in SQL now-a-day .....

- Jeff
Go to Top of Page

IHaveNoClue
Starting Member

USA
2 Posts

Posted - 02/11/2003 :  08:28:12  Show Profile  Reply with Quote
quote:

you need to repeat the CASE expression 3 times.

SELECT
tblClientMaster.sName AS 'ClientName',
Case sName WHEN 'Void' THEN " " ELSE sName END as sName,
CASE sName WHEN 'Void' THEN " " ELSE sDescription END as sDescription,
CASE sName WHEN 'Void' THEN " " ELSE iSort END as iSort
FROM
...

Also, note that naming fields with prefixes based on their datatype isn't really the "hip" thing to do in SQL now-a-day .....

- Jeff



Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.04 seconds. Powered By: Snitz Forums 2000