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
Program running on Citrix Published Desktop needs admin rights to run
Corel Draw 9 Help - Image Editing
I need guidance in tweaking my Nightly Cron Backup script to properly remove old files.
BACKUP of OutlookXP
NTKERN.VXD device loader ... could not load the device
Can't sign on to domain after Ghost restore
problem displaying an image inside CGI
Foreign Keys
Activesync permission error
problems replicating public folders from Exchange 2003 to Exchange 2007