SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Tables


Tables

Author
Message
Sean Lange
Sean Lange
One Orange Chip
One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)

Group: General Forum Members
Points: 26006 Visits: 17528
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 Modens 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)
Steve Cullen
Steve Cullen
Right there with Babe
Right there with Babe (745 reputation)Right there with Babe (745 reputation)Right there with Babe (745 reputation)Right there with Babe (745 reputation)Right there with Babe (745 reputation)Right there with Babe (745 reputation)Right there with Babe (745 reputation)Right there with Babe (745 reputation)

Group: General Forum Members
Points: 745 Visits: 1226
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.


JF1081
JF1081
SSC-Addicted
SSC-Addicted (454 reputation)SSC-Addicted (454 reputation)SSC-Addicted (454 reputation)SSC-Addicted (454 reputation)SSC-Addicted (454 reputation)SSC-Addicted (454 reputation)SSC-Addicted (454 reputation)SSC-Addicted (454 reputation)

Group: General Forum Members
Points: 454 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?
Oleg Netchaev
Oleg Netchaev
SSCommitted
SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)

Group: General Forum Members
Points: 1777 Visits: 1813
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
Steve Jones
Steve Jones
SSC Guru
SSC Guru (62K reputation)SSC Guru (62K reputation)SSC Guru (62K reputation)SSC Guru (62K reputation)SSC Guru (62K reputation)SSC Guru (62K reputation)SSC Guru (62K reputation)SSC Guru (62K reputation)

Group: Administrators
Points: 62294 Visits: 19102
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
My Blog: www.voiceofthedba.com
webrunner
webrunner
SSCarpal Tunnel
SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)

Group: General Forum Members
Points: 4130 Visits: 3881
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

-------------------
"I love spending twice as long and working twice as hard to get half as much done!" – Nobody ever.
Ref.: http://www.adminarsenal.com/admin-arsenal-blog/powershell-how-to-write-your-first-powershell-script

"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
Daniel Bowlin
Daniel Bowlin
SSCarpal Tunnel
SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)

Group: General Forum Members
Points: 4092 Visits: 2629
Easy question, no trick. Doh!
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search