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

    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 SitingsTwitterFacebookLinkedInHomePageFlickrLTD RSS Feed
    2421 views
    Instapaper

    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.)