|
|
|
SSCertifiable
       
Group: General Forum Members
Last Login: Today @ 2:31 AM
Points: 5,235,
Visits: 7,033
|
|
|
|
|
|
Old Hand
      
Group: General Forum Members
Last Login: Yesterday @ 9:39 PM
Points: 322,
Visits: 476
|
|
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 @ 3:04 PM
Points: 5,101,
Visits: 20,200
|
|
|
|
|
|
Hall of Fame
       
Group: General Forum Members
Last Login: Yesterday @ 10:44 AM
Points: 3,452,
Visits: 2,527
|
|
| Thanks, Hugo -- a nice one to end my day with!
|
|
|
|
|
Hall of Fame
       
Group: General Forum Members
Last Login: Today @ 4:53 AM
Points: 3,189,
Visits: 4,145
|
|
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 @ 9:06 AM
Points: 9,367,
Visits: 6,465
|
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Today @ 4:20 AM
Points: 1,400,
Visits: 6,890
|
|
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: Today @ 4:33 AM
Points: 3,046,
Visits: 1,302
|
|
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!
|
|
|
|