|
|
|
SSCrazy Eights
        
Group: General Forum Members
Last Login: Today @ 10:35 AM
Points: 8,616,
Visits: 8,256
|
|
|
|
|
|
Mr or Mrs. 500
      
Group: General Forum Members
Last Login: Wednesday, September 19, 2012 8:39 AM
Points: 595,
Visits: 1,226
|
|
I think too many (myself included) are looking for trick questions. Nice simple question today. Thank you for that.
Converting oxygen into carbon dioxide, since 1955.
|
|
|
|
|
SSC-Addicted
      
Group: General Forum Members
Last Login: Tuesday, December 07, 2010 8:13 AM
Points: 436,
Visits: 322
|
|
Personally, I thought it was a trick trick question. Too easy to be that easy, but the writer was expecting me to think that so I decided it was that easy.
I think what the author was trying to point out is that you wouldn't normally set the default value of a column to null. Correct me if I am wrong, but the default value for an empty column when a row is added is NULL?
|
|
|
|
|
SSCommitted
      
Group: General Forum Members
Last Login: 2 days ago @ 10:53 AM
Points: 1,662,
Visits: 1,709
|
|
This is a good basic question, thank you.
I also paused for a minute before answering trying to figure out what could be a possible reason for this table not to be created? Default constraints can be null. The real question is why would anybody do it? What I mean is that if you remove the word default and the parenthesis around word null then you get pretty much same effect. For example,
create table #TempTable ( Tempnum int null, Tempname varchar (10) null ); go -- table created;
insert into #temptable default values; -- record inserted go The insert above clearly inserts a record with default values which happen to be null out of the box due to columns' definitions, so Tempnum int null is sufficient to instruct the engine that for any inserts null is used in absence of value. Maybe somebody knows a valid reason to create a table with column default (null). The only reason I can come up is that assumming white background and dark letters in the editor, typing extra words saves a little bit of electricity if left on the screen for long enough time, so Tempnum int default (null) is more environmentally friendly than simple Tempnum int null
Oleg
|
|
|
|
|
SSC-Dedicated
           
Group: Administrators
Last Login: Today @ 12:07 PM
Points: 31,431,
Visits: 13,741
|
|
|
|
|
|
SSCrazy
      
Group: General Forum Members
Last Login: Yesterday @ 2:10 PM
Points: 2,117,
Visits: 2,211
|
|
tommyh (6/16/2010)
SanjayAttray (6/16/2010) It will get created. Is there a reason, it would not get created ?Well with 17% wrong answers i would say that some people think that there could be a reason it would not be created. So a good question (bad question would be one with 100% correct answers)
Well, maybe others made my mistake: I thought varchar (10) would fail because of the space between the 'r' and the '('. I should have known better.
Good question even if it is straightforward to most.
Thanks.
- webrunner
------------------- "The chemistry must be respected." - Walter White
"A SQL query walks into a bar and sees two tables. He walks up to them and says 'Can I join you?'" Ref.: http://tkyte.blogspot.com/2009/02/sql-joke.html
|
|
|
|
|
SSCrazy
      
Group: General Forum Members
Last Login: Yesterday @ 1:10 PM
Points: 2,673,
Visits: 2,418
|
|
| Easy question, no trick. Doh!
|
|
|
|