Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7915149
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T14:21:46+00:00 2026-06-03T14:21:46+00:00

I have a single row in a table variable that looks like this: CanEdit

  • 0

I have a single row in a table variable that looks like this:

CanEdit | CanView | CanAdd | CanDelete

All columns are bit fields. I need to convert this table to a comma-delimited string like the following:

  • If the user has true for each column…
    E,V,A,D

  • If the user only has Edit and Add…
    E,A

How can I do this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T14:21:48+00:00Added an answer on June 3, 2026 at 2:21 pm

    As it’s a fixed set, it can be done directly as follows.

    SUBSTRING(
        CASE WHEN CanEdit   = 1 THEN ',E' ELSE '' END
      + CASE WHEN CanView   = 1 THEN ',V' ELSE '' END
      + CASE WHEN CanAdd    = 1 THEN ',A' ELSE '' END
      + CASE WHEN CanDelete = 1 THEN ',D' ELSE '' END,
      2,
      7
    )
    

    That said, it is very rare that this is recommended.

    If you are refactoring your data, this is reversing the atomicity of your data and is considered a fundamentally problematic anti-pattern in SQL.

    If you are doing this for presentation in a client, doing this in SQL couples your data layer and presentation layer, another anti-pattern.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a query that looks like this: select id , int1 , int2
I have a single row of data in a SQL Server table that I'm
i have a table with single row (textfield) and Add Row button, when user
I have a mysql query that targets a single column in a single row
Using SQL Server 2008. I have a table variable with a single column and
Here is my scenario: I have a single table with 2 columns. ID and
I have a 5 million row table that gets hit with a specific query
The javascript code I now have can toggle a single row of data. Whether
I have a Excel File, i am able to read single row from Excel
We have a single SVN repository with multiple related projects. Like so... \repo \Project1

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.