SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 List only bit fields?
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

WJHamel
Aged Yak Warrior

USA
614 Posts

Posted - 04/23/2012 :  09:31:27  Show Profile  Reply with Quote
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

Norway
3241 Posts

Posted - 04/23/2012 :  09:38:12  Show Profile  Reply with Quote
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
Flowing Fount of Yak Knowledge

5152 Posts

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

Edited by - sunitabeck on 04/23/2012 09:39:40
Go to Top of Page

khtan
In (Som, Ni, Yak)

Singapore
16746 Posts

Posted - 04/23/2012 :  09:39:54  Show Profile  Reply with Quote
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
Time is always against us

Go to Top of Page

Lumbago
Norsk Yak Master

Norway
3241 Posts

Posted - 04/23/2012 :  09:41:05  Show Profile  Reply with Quote
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

USA
614 Posts

Posted - 04/23/2012 :  10:00:03  Show Profile  Reply with Quote
Ha. Got it. Thanks all.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000