|
|
|
SSCertifiable
       
Group: General Forum Members
Last Login: Yesterday @ 2:13 PM
Points: 5,237,
Visits: 7,044
|
|
|
|
|
|
Old Hand
      
Group: General Forum Members
Last Login: Yesterday @ 8:38 PM
Points: 322,
Visits: 477
|
|
You have two answers that are potentially correct here.
None, and None unless the rest of the command specifies one.
Shame I picked the wrong one!
Edit: I stand corrected. The CREATE INDEX has to be a separate command. Missed that.
|
|
|
|
|
SSCertifiable
       
Group: General Forum Members
Last Login: Yesterday @ 4:00 PM
Points: 5,102,
Visits: 20,205
|
|
|
|
|
|
Hall of Fame
       
Group: General Forum Members
Last Login: Yesterday @ 2:42 PM
Points: 3,457,
Visits: 2,532
|
|
| Thanks, Hugo -- a nice one to end my day with!
|
|
|
|
|
Hall of Fame
       
Group: General Forum Members
Last Login: Yesterday @ 1:41 AM
Points: 3,190,
Visits: 4,147
|
|
I can create an index by means of a unique constraint:
CREATE TABLE dbo.QotD (KeyColumn int NOT NULL PRIMARY KEY, RefColumn int NOT NULL, -- More column definitions CONSTRAINT FK_RefTab FOREIGN KEY (RefColumn) REFERENCES dbo.RefTab(RefTabKey), -- More constraints CONSTRAINT UQ_RefColumn UNIQUE(RefColumn) ); Doesn't it count as answer #2?
|
|
|
|
|
SSCrazy Eights
        
Group: General Forum Members
Last Login: Yesterday @ 6:51 AM
Points: 9,373,
Visits: 6,470
|
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Yesterday @ 4:31 AM
Points: 1,400,
Visits: 6,892
|
|
I also took answer number 2. Forgot that you cannot specify an index directly in a create table statement. D'oh!
Thanks - I was wondering why my answer was incorrect too. I thought it strange that Hugo might have made a mistake!
BrainDonor Linkedin
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Friday, May 17, 2013 4:24 AM
Points: 1,158,
Visits: 642
|
|
Hugo - nice question. Surprised only 15% have this correct so far...
|
|
|
|
|
Hall of Fame
       
Group: General Forum Members
Last Login: Yesterday @ 9:32 AM
Points: 3,046,
Visits: 1,306
|
|
vk-kirov (6/26/2012)
I can create an index by means of a unique constraint: CREATE TABLE dbo.QotD (KeyColumn int NOT NULL PRIMARY KEY, RefColumn int NOT NULL, -- More column definitions CONSTRAINT FK_RefTab FOREIGN KEY (RefColumn) REFERENCES dbo.RefTab(RefTabKey), -- More constraints CONSTRAINT UQ_RefColumn UNIQUE(RefColumn) ); Doesn't it count as answer #2? 
That's exactly what I thought - but then decided that given this was a question from Hugo Kornelis it wouldn't be that sneaky, so went for option 1.
Thanks for the question.
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Friday, May 17, 2013 9:52 AM
Points: 1,356,
Visits: 4,761
|
|
vk-kirov (6/26/2012) I can create an index by means of a unique constraint
That's exactly the basis on which I answered "None unless the rest of the statement creates one", which I therefore believe should be the correct answer. Particularly given that the previous "index defaults" question was about the possibility of a Unique constraint appearing later in the statement!
|
|
|
|