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 190427
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T16:15:19+00:00 2026-05-11T16:15:19+00:00

I am writing a report to return details about an object (‘files’) in my

  • 0

I am writing a report to return details about an object (‘files’) in my database. My application lets users create their own flags for use against file objects. Flags basically consist of a name, then flag instances store a bit value to indicate whether it is set for the parent file object.

I want to write a query that returns one row per file in the database, where the first few columns in the result set contain the file details (id, name, size etc) and the remaining columns are the flag names, with bit values returned to indicate whether the flag is set for the given file row.

Does that make sense? How do i go about writing the query?

Thanks for any help.

Edit: Clarification..

As part of this query, I need to run a sub query that returns the flags that have been created by the user (I do not know these at design time), then incorporate a check for each flag value in the main query to return details about the files.

Simplified schema as follows:

  • File {Id, Name}
  • Flag {Id, Name}
  • FileFlags {FileId, FlagId} – a row in this table indicates that the flag is set for the file

I need the query to return a result set with columns something like this:

FileId FileName Flag1Name Flag2Name …. FlagNName

  • 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-05-11T16:15:20+00:00Added an answer on May 11, 2026 at 4:15 pm

    You could start by looking at the Pivot function available in SQL Server 2005+. With that and some string concatenation you should be able to assemble a query for any number of columns

    Based on your comment your select would look something like this:

            SELECT <non-pivoted column>,
    
                [first pivoted column] AS <column name>,
    
                [second pivoted column] AS <column name>, ...
        From Table 
        PIVOT (
    ...
    FOR 
    ...
    )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i am developing a website on writing reports ...users can comment on a report
I'm writing a report to get result from mysql database. The query has one
Im writing a report with Reporting services that is almost always only going to
I'm writing a report and presentation for my college titled Protection runtime program in
currently im writing a test for a report function the more functionality the project
I'm writing some code that takes a report from the mainframe and converts it
I am currently writing a formal research report, and I'll be including code with
I am writing the middleware for a cocoa application, and am debating over how
I'm writing a C application which uses the pcap library to log how much
Possible Duplicate: Workflow for statistical analysis and report writing I have been programming with

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.