Click here to Skip to main content
13,628,146 members
Rate this:
 
Please Sign up or sign in to vote.
See more:
I have database table in sql server in which some columns are bit fields which serially located from Sl. No. 6 to 13.
Now I want to extract the column name of the table from Sl. No. 6 to 13 which are true and leave all which are not true i.e. false.


Please suggest me the database query for the purpose.

What I have tried:

How to extract the column names for true bit fields
Posted 19-Feb-18 23:11pm
Updated 20-Feb-18 19:15pm
Comments
Naga Sindhura 21-Feb-18 4:57am
   
under your schema, Try to use to query with sys.columns to extract columns information and sys.systypes for data type. xtype or system_type_id 104 is for bit. I hope this will help you..
Naga Sindhura 21-Feb-18 4:58am
   
sys.columns and sys.systypes are tables
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

That isn't really possible: it would require that the number of columns returned was different for each row in the returned data, and SQL just isn't set up for that.
You could do it, by converting the column names to a comma delimited list, but ... it'd be nasty to do, and would still require subsequent processing in your presentation language.
As a result, I'd strongly suggest that you returned all the columns and just process it in the presentation language instead of faffing about with complicated SQL at all here.
  Permalink  
v2
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

So, how can we show the same in comma separated normal text.?

please explain the same in detail
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Cookies | Terms of Service
Web01 | 2.8.180712.1 | Last Updated 21 Feb 2018
Copyright © CodeProject, 1999-2018
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100