• Esalter (11/11/2009)


    one thing I've frequently come across that would be extremely useful is the ability to define Foreign keys that are a compound key (concatenated columns). Do you know if this is available in current versions of SQL (or ever likely to be)?

    Multi-column Foreign keys? That's been possible for many versions.

    Create table Parent (

    ParentID int identity primary key,

    ChildID1 int,

    ChildID2 int,

    SomeArbString varchar(10)

    )

    Create table Child (

    ChildID1 int not null,

    ChildID2 int not null,

    SomeDate datetime

    )

    ALTER TABLE Child ADD CONSTRAINT pk_Child PRIMARY KEY (ChildID1, ChildID2)

    ALTER TABLE Parent ADD CONSTRAINT fk_Parent_Child FOREIGN KEY (ChildID1, ChildID2) REFERENCES Child (ChildID1, ChildID2)

    Got nothing to do with indexes though

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass