I am using SQL Server 2008r2.
Here is what I am trying to accomplish:
I have a table with the design:
Flag Text
________________________
0 'No Error'
1 'Bad Data'
2 'Bad Header'
4 'Unknown error'
My second table is designed:
ID Flags
_______________________
500 0
501 3
502 4
504 6
550 0
The flags in the second table represent a bitwise combination of the flags in the first table (e.g. Flags = 3 is 'Bad Data' AND 'Bad Header', Flags = 6 is 'Bad Header' AND 'Unknown error').
I want a query that will produce the following:
ID ConcatText
____________________________
500 'No Error'
501 'Bad Data, Bad Header'
502 'Unknown error'
504 'Bad Header, Unknown error'
550 'No Error'
What is the best way to achieve this without the use of user-defined functions, or user-defined stored procedures?
Thanks for any help.