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
Need Exchange 2003 POP3 connector to leave mail on server
PXE Booting to Ghost with Multiple NIC Drivers
How to copy / replace tables in MS SQL Server Management Studio 2005?
Which RPM does libhistory.so.5 reside in
Cannot log in to CompanyWeb or Sharepoint Central Administration
Remove duplicate Contact list in Outlook Address Book
MS Access - Using Automatic Resizable (Adjusting) Forms
RRAS Enable Fragmentation Checking
Repeated browser event ID 8021 and 8032 then server loses connction to domain with nelogon event 5719
Copy data from Access table to SQL Server 2005 table when there is an autonumber