SQL Server view combine fields in results
Posted on 2011-10-26
I have a table in sql server. I have 4 fields within the table that are boolean fields, either true or false. The fields are friend, relative, business and other. The view I am building will return other fields in the table, but for those 4 fields I want to show one field. For any of them that are true, return in one field the results as words. So a result set would look like this for a row that has true for each one:
ID LName FName Address Relationship
21 Smith John 100 Whatever Dr Friend, Relative, Business, Other
The relationship will usually have just one or 2 of the fields set to true, but it could be anywhere from 1-4 of them. Is there a way to do this? Thanks.