Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 retrieving column name using its property

Author  Topic 

Yonkouturko
Yak Posting Veteran

59 Posts

Posted - 2013-11-14 : 03:24:36
say i have 4 columns
2 varchar
2 boolean
i want to retrieve the boolean columns..
how will i do that or how will i code that..

suggestions will be appreciated!!!
any help will be gratified!! thank you!!!

bandi
Master Smack Fu Yak Hacker

2242 Posts

Posted - 2013-11-14 : 04:06:57
SELECT TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, COLUMN_NAME, DATA_TYPE
FROM INFORMATION_SCHEMA.COLUMNS
WHERE DATA_TYPE = 'bit' -- Here is the filter.. You can filter the result based table name too

--
Chandu
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-11-14 : 05:33:46
Keep in mind that it will show you all bit columns on the database unless you put an additional filter on table/view name.

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

Yonkouturko
Yak Posting Veteran

59 Posts

Posted - 2013-11-14 : 12:51:29
thank you visakh16 and bandi!!
Go to Top of Page

bandi
Master Smack Fu Yak Hacker

2242 Posts

Posted - 2013-11-14 : 23:12:15
quote:
Originally posted by Yonkouturko

thank you visakh16 and bandi!!



welcome :)

--
Chandu
Go to Top of Page
   

- Advertisement -