Login or Sign Up to become a member!
LessThanDot Sit Logo

LessThanDot

Data Management

Less Than Dot is a community of passionate IT professionals and enthusiasts dedicated to sharing technical knowledge, experience, and assistance. Inside you will find reference materials, interesting technical discussions, and expert tips and commentary. Once you register for an account you will have immediate access to the forums and all past articles and commentaries.

LTD Social Sitings

Lessthandot twitter Lessthandot Linkedin Lessthandot friendfeed Lessthandot facebook Lessthandot rss

Note: Watch for social icons on posts by your favorite authors to follow their postings on these and other social sites.

Your profile

Search

XML Feeds

Google Ads

« SQL Friday, The Best SQL Server Links Of The Past Week Episode 7SQL server Linked server between 2005 64bits and a 2000 32 bits server. »
comments
Rate Post:
submit to reddit Digg!FacebookDotnetkicks

This question popped up on the MSDN forum today: Status of BIT type columns

Here is a way to quickly find all the columns in your database which allow NULLS

  1. SELECT table_name,column_name
  2. FROM information_schema.columns
  3. WHERE is_nullable ='YES'
  4. ORDER BY table_name,column_name

Now you might have noticed that some of these are views. You can join with information_schema.tables and filter on table_type = 'base table' to list just the tables.

  1. SELECT c.table_name,c.column_name,t.table_type
  2. FROM information_schema.columns c
  3. join information_schema.tables t ON c.table_name = t.table_name
  4. WHERE is_nullable ='YES'
  5. and table_type = 'base table'
  6. ORDER BY table_name,column_name

To list all the columns in your database regardless if they are in a view or a table and if they allow NULLS or not use this

  1. SELECT table_name,column_name,is_nullable
  2.  FROM information_schema.columns
  3. ORDER BY table_name,column_name

You can also find this in our SQL Server Admin Hacks wiki

*** If you have a SQL related question try our Microsoft SQL Server Programming forum or our Microsoft SQL Server Admin forum

About the Author

User bio imageDenis has been working with SQL Server since version 6.5. Although he worked as an ASP/JSP/ColdFusion developer before the dot com bust, he has been working exclusively as a database developer/architect since 2002. In addition to English, Denis is also fluent in Croatian and Dutch, but he can curse in many other languages and dialects (just ask the SQL optimizer) He lives in Princeton, NJ with his wife and three kids.
Social SitingsTwitterFacebookLinkedInHomePageLTD RSS Feed
1673 views
submit to reddit Digg!FacebookDotnetkicks

Comments and Feedback

No feedback yet

Leave a comment


Your email address will not be revealed on this site.

Your URL will be displayed.
(Line breaks become <br />)
(Name, email & website)
(Allow users to contact you through a message form (your email will not be revealed.)