• Koen Verbeeck (6/27/2012)


    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? 🙂

    It's possible, but I doubt a 1-1 foreign key relationship is very useful 😀

    I also took answer number 2. Forgot that you cannot specify an index directly in a create table statement. D'oh!

    I knew you couldn't create the index, but a 1-1 cardinality does occasionally exist, so a Uniqueness constraint specified to help the FK should be a valid way to get a Uniqueness index onto a table in the create statement.



    --Mark Tassin
    MCITP - SQL Server DBA
    Proud member of the Anti-RBAR alliance.
    For help with Performance click this link[/url]
    For tips on how to post your problems[/url]