Click here to Skip to main content
15,910,886 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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
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

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.
 
Share this answer
 
v2
So, how can we show the same in comma separated normal text.?

please explain the same in detail
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900