Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 14973

[RESOLVED] SQL Select and resolve bitmask values

$
0
0
I have a column in my table called MonitoredBy and it's a bitmask of 3 possible values.
This is how I am working with it in C#:
Code:

        enum SystemDataMonitoredBy
        {
            None = 0,
            Motorola = 1,
            StateNCC = 2,
            Customer = 4
        }

I am writing a query that my boss wants to run in sql server. So when I select tblSystemData.MonitoredBy it's returning 7 when all bits are on. She wants that resolved.
I don't know if she would like three columns back listing Motorola, State NCC and Customer with a Y or N in each column.
Of if she would prefer one column saying "Motorola, StateNCC, Customer". And sometimes it would say "Motorola", sometimes "Motorola, Customer" etc.
I think I can handle the former on my own. How would I do the latter? I could do it with a big case...else of 7, 6, 5, etc which is fine for this small example, but what if there were more values making that unwieldy?
Thanks.

Viewing all articles
Browse latest Browse all 14973

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>