Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase ««12

Tables Expand / Collapse
Author
Message
Posted Thursday, June 17, 2010 8:06 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 9:10 AM
Points: 13,230, Visits: 12,709
I too kept looking at the syntax thinking there must be something in there...then wondered if it were one of the questions about exactly how it was worded and intended. When all was said and done I decided there was no syntax error so of course it would be created. Nice straight forward question.

_______________________________________________________________

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 Moden's splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
Post #938930
Posted Thursday, June 17, 2010 8:24 AM
Mr or Mrs. 500

Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr 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.

Post #938948
Posted Thursday, June 17, 2010 9:17 AM
SSC-Addicted

SSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-Addicted

Group: General Forum Members
Last Login: Tuesday, December 7, 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?

Post #938998
Posted Thursday, June 17, 2010 9:20 AM
SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: 2 days ago @ 8:33 AM
Points: 1,676, Visits: 1,760
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
Post #939002
Posted Thursday, June 17, 2010 9:54 AM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: Administrators
Last Login: Today @ 10:42 AM
Points: 31,284, Visits: 15,747
We are getting a lot of new people writing questions, so there isn't this history of "trying to make it hard" with them. Kind of good.

Nice question, I saw it a few months ago, and went to answer today, thinking there was some trick as well.







Follow me on Twitter: @way0utwest

Forum Etiquette: How to post data/code on a forum to get the best help
Post #939033
Posted Thursday, June 17, 2010 10:14 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Yesterday @ 1:33 PM
Points: 2,414, Visits: 2,826
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


-------------------
"Operator! Give me the number for 911!" - Homer Simpson

"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
Post #939058
Posted Thursday, June 17, 2010 11:32 AM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Tuesday, November 4, 2014 12:48 PM
Points: 2,818, Visits: 2,566
Easy question, no trick. Doh!
Post #939129
« Prev Topic | Next Topic »

Add to briefcase ««12

Permissions Expand / Collapse