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
 General SQL Server Forums
 New to SQL Server Programming
 List only bit fields?

Author  Topic 

WJHamel
Aged Yak Warrior

651 Posts

Posted - 2012-04-23 : 09:31:27
In SSMS, i'm trying to list only the columns in a table that are bit fields. Reason being, there is a checkbox in our front end app that the customer wants "checked" (or set to '1') by default. Our engineers do not have a mapping that shows which sql field is mapped to that checkbox in their Delphi front end, and they are less than cooperative in providing the dba's with the info we need to get our job done, so we're left to use process of elimination go one by one and set the default values in sql to '1' until we see that box "checked" in the app. It would expedite things for me if i could produce a list of the bit fields in the tables that i suspect hold that column. Can this be done?

Second question: What's the best way to poison the coffee of an engineer without getting traced back to me?

Lumbago
Norsk Yak Master

3271 Posts

Posted - 2012-04-23 : 09:38:12
select * from INFORMATION_SCHEMA.COLUMNS where TABLE_NAME = 'tableName' and DATA_TYPE = 'bit'

- Lumbago
My blog-> http://thefirstsql.com/2011/07/08/how-to-find-gaps-in-identity-columns-at-the-speed-of-light/
Go to Top of Page

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2012-04-23 : 09:39:11
[code]SELECT * FROM INFORMATION_SCHEMA.[COLUMNS] WHERE DATA_TYPE = 'bit'[/code]As for your second question, Siri has a brilliant answer, which I leave as an exercise to the reader.
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2012-04-23 : 09:39:54
i think your second question is easier than the first.

the key is to use the command in red

SET TRACE OFF

UPDATE CUP
SET COFFEE = COFFEE + POISON
WHERE OWNER = 'ENGINEER'

SET TRACE ON



KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

Lumbago
Norsk Yak Master

3271 Posts

Posted - 2012-04-23 : 09:41:05
select 'alter table ' + TABLE_NAME + ' alter column ' + COLUMN_NAME + ' bit default(1)' from INFORMATION_SCHEMA.COLUMNS where DATA_TYPE = 'bit'

- Lumbago
My blog-> http://thefirstsql.com/2011/07/08/how-to-find-gaps-in-identity-columns-at-the-speed-of-light/
Go to Top of Page

WJHamel
Aged Yak Warrior

651 Posts

Posted - 2012-04-23 : 10:00:03
Ha. Got it. Thanks all.
Go to Top of Page
   

- Advertisement -