• ScottPletcher (7/30/2014)


    Keith Tate (7/30/2014)

    What can happen if null is not defined?

    If you don't set the NULL option then it will be nullable.

    create table Test1 (

    ExpirationDate datetime);

    go

    That's not true. The default could be NULL or NOT NULL, and which one can be influenced by both database and/or session settings. Therefore, you should always explicitly specify "NULL" or "NOT NULL" on every column, since you won't know the database and/or session settings if/when the code is run again if the future.

    I agree we should always define NULL or NOT NULL. What settings can change or influence this? I am not familiar with that.

    _______________________________________________________________

    Need help? Help us help you.

    Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

    Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.

    Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
    Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
    Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
    Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/