April 25, 2013 at 9:03 pm
Comments posted to this topic are about the item Create Table
_______________________________________________________________
To get quick answer follow this link:
http://www.sqlservercentral.com/articles/Best+Practices/61537/
April 25, 2013 at 11:00 pm
This was removed by the editor as SPAM
April 25, 2013 at 11:11 pm
Good Information..
--
Dineshbabu
Desire to learn new things..
April 25, 2013 at 11:14 pm
Kapil, very good question. 🙂
Thanks
Vinay Kumar
-----------------------------------------------------------------
Keep Learning - Keep Growing !!!
April 26, 2013 at 12:46 am
Easy one to close off the week, thanks!
Need an answer? No, you need a question
My blog at https://sqlkover.com.
MCSE Business Intelligence - Microsoft Data Platform MVP
April 26, 2013 at 1:01 am
Koen Verbeeck (4/26/2013)
Easy one to close off the week, thanks!
+1 - thanks for the question
-------------------------------Posting Data Etiquette - Jeff Moden [/url]Smart way to ask a question
There are naive questions, tedious questions, ill-phrased questions, questions put after inadequate self-criticism. But every question is a cry to understand (the world). There is no such thing as a dumb question. ― Carl Sagan
I would never join a club that would allow me as a member - Groucho Marx
April 26, 2013 at 3:49 am
I first focused on the reference to a unique constraint rather than the primary key, thinking that was the issue of the question. I almost got it wrong because of that, as I had first not given enough attention to the other details of the code.
I guess that many people will get this question right for the wrong reasons. (Many people think that a foreign key should always reference the primary key).
April 26, 2013 at 4:02 am
Hugo Kornelis (4/26/2013)
I first focused on the reference to a unique constraint rather than the primary key, thinking that was the issue of the question. I almost got it wrong because of that, as I had first not given enough attention to the other details of the code.I guess that many people will get this question right for the wrong reasons. (Many people think that a foreign key should always reference the primary key).
Same happened with me, but suddenly i see the data type size and i got it. Actually i read this one few time ago, that's help me. 🙂
Thanks
Vinay Kumar
-----------------------------------------------------------------
Keep Learning - Keep Growing !!!
April 26, 2013 at 4:06 am
Can someone please point me towards the place where the documentation explains that a foreign key column must have the same length as the column that it references? I can't see it in the link to MSDN provided in the answer.
The Create Table documentation here: does say that that both columns must both be of the same data type, but it doesn't mention length.
April 26, 2013 at 5:15 am
This is what I get for trusting that voice in my head that says, "No, that's way too obvious." :crazy:
ron
-----
a haiku...
NULL is not zero
NULL is not an empty string
NULL is the unknown
April 26, 2013 at 6:26 am
Thanks for good question.
I just looked at the syntax, column name and column data type and then length of column.
April 26, 2013 at 6:56 am
Mick Gillatt (4/26/2013)
Can someone please point me towards the place where the documentation explains that a foreign key column must have the same length as the column that it references? I can't see it in the link to MSDN provided in the answer.The Create Table documentation here: does say that that both columns must both be of the same data type, but it doesn't mention length.
Sorry for that but I also didn't find that information that foreign key must have same length as referencing columns so in answer I placed the link of constraint.
I found this situation when I working on a script so think of put it as a QOTD!!
_______________________________________________________________
To get quick answer follow this link:
http://www.sqlservercentral.com/articles/Best+Practices/61537/
April 26, 2013 at 6:57 am
Thanks for the question..Kapil
April 26, 2013 at 7:05 am
Hugo Kornelis (4/26/2013)
I first focused on the reference to a unique constraint rather than the primary key, thinking that was the issue of the question. I almost got it wrong because of that, as I had first not given enough attention to the other details of the code.I guess that many people will get this question right for the wrong reasons. (Many people think that a foreign key should always reference the primary key).
nah, that one I had... I've had to do enough FK's to Unique constraints in my life to remember that lesson...
I'm just glad that I re-read it... and noticed the different column sizes.
April 26, 2013 at 7:09 am
I was initially leaning toward the right answer for the right reason, then talked myself out of it, thinking that SQL Server would be able to handle it. :hehe:
Of course, I also don't see why it can't implicitly handle the GROUP BY statement.
Viewing 15 posts - 1 through 15 (of 29 total)
You must be logged in to reply to this topic. Login to reply