Microsoft
Software
Hardware
Network
Question : COALESCE and AS with CASE WHEN statment, other ways?
Can't figure out if this is the only way to achieve wanted result. Probably not...i hope, but im stuck.
In a data retrival stored procedure i provide an integer that determines if some information should be hidden in query. A user might have the right to see scheduled item but not the information is scheduled for.
The information is an COALESCE as it has various of information to show due to joins. The only way I have come up with is the following:
R.ResourceText+', '+
COALESCE( CASE
WHEN ( RS.CreatedBy_SystemCompany
_ID_FK = @syscompid
OR
RS.UpdatedBy_SystemCompany
_ID_FK = @syscompid
OR
INV.CreatedBy_SystemCompan
y_ID_FK = @syscompid
OR
PER.CreatedBy_SystemCompan
y_ID_FK = @syscompid
OR
PRO.CreatedBy_SystemCompan
y_ID_FK = @syscompid
) THEN null ELSE ' | INFORMATION UNAVAILABLE |'
END,
FE.Feed_Title+' ('+FT.FeedType_Title+')',
FE.Feed_Title,
WO.WorkOrder_Title,
EV.EventFlowOrder_Title,
RS.ResourceSchedule_Title + ' | '+RS.ResourceSchedule_Desc
ription,
RS.ResourceSchedule_Title,
'not found' ) as RSTitle
Isn't there a smarter syntax or way? In above case I would have to use the CASE statement in all COALESCE's that needs information to be hidden.
Thanks in advance.
Answer : COALESCE and AS with CASE WHEN statment, other ways?
Yes that's what I meant.
In my opinion a function should increase performance however that's not always the case.
It's just a matter of trying.
Random Solutions
Error Handler For 404
PayPal Donation button and IPN
SQL Error when changing data type (IMPERSONATE) error
SUMPRODUCT and ISNUMBER(MATCH
What authority does the signin that uses IBMDA400 need to have to the AS400?
Dreamweaver MX pop-up menus hidden behind .swf
Monitoring Xen VPS's
HP BIOS Upgrade Website Confusion
teenager mysteriously obtaining administrator rights
Lotus Notes: "NSD is running" error