Hello,
Uh oh! SQL guy is on vacation again!
I'm trying to feed a "Race" field on an RDLC report. My database has a person table with bit fields to indicate the race(s) a person belongs to.
The layout is something like this:
person_ID | name | DOB | IsAsian | IsBlack | IsNativeHawaiian | IsAlaskaNative | IsWhite
A person can belong to more than one race group. I'm trying to write a function that would output a string of each race the person belongs to. For example, if IsAlaskaNative='1' AND IsWhite='1' the output would be "Alaskan Native, White".
Any help you can provide will be greatly appreciated.
Thanks!
CASE WHEN raceBits & 1 > 0 THEN ', Asian' ELSE '' END +
CASE WHEN raceBits & 2 > 0 THEN ', Black' ELSE '' END +
CASE WHEN raceBits & 4 > 0 THEN ', Alaskan Native' ELSE '' END +
CASE WHEN raceBits & 8 > 0 THEN ', White' ELSE '' END,
1, 2, '') AS Race