Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Help with Case and Null
Message
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Miscellaneous
Thread ID:
00969104
Message ID:
00969105
Views:
14
This message has been marked as the solution to the initial question of the thread.
Kirk,

You may want to check COALESCE() finction in BOL.

>In the code below, if the charge type is "I" it gets the description from the inventory file, otherwise it gets the description from the procedure file. My problem is, that they may have a manual inventory item that is not in the coInv table, in this case, the chargetype is still "I" and the description is stored in the coCaseData.ManualDesc table/field. So my question is, can anyone help me reword the case statement so that if the chargetype is I, and the Select from coInv comes back null, that I can perform the other subquery to get the proper desc. This snippit is from a stored procedure. Maybe this should portion should be done in a SQL-UDF?
>
>Thanks
>
>
>case dbo.ChargeReportLog.ChargeType
>   when 'I' then (select coInv.primedesc from dbo.coinv where coinv.invid=dbo.ChargeReportLog.invID)
>   else (select description from dbo.coProc where coProc.procID=dbo.ChargeReportLog.InvID)
>end as PrimeDesc
>
--sb--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform