I have some query logic that needs to return two dynamically created columns based on two conditional tests so that
- If Test1 is True then the values for columns 1 and 2 are always the same regardless of the results of Test2.
- If Test1 is False then Test2 determines the value of Column2
Because the CASE statement only produces one column I am having to repeat Test1 and then nest Test2 in the ELSE portion of the second iteration of Test1. I was hoping that someone might have a different approach that would reduce the amount of testing
being performed in the SQL. I did see the post at
http://social.msdn.microsoft.com/Forums/en-US/transactsql/thread/a0e45c7d-eedd-41ca-89f9-163c4dadc1a7/ that doesn't offer much hope but I thought I'd ask.
For what it's worth I'm posting the heart of my logic below. The test is performing bitwise comparisons to determine (Test1:) If the currently logged in user has access to a document and, if not (Test2) what they need to do to gain access. @Access
will end up as a parameter in the stored procedure once I finalize this.
View Complete Post