Create Table Statement

  • Hi,

    I am puzzeled about a Create Table statement.

    The statement is:

    Create Table abc

    ( Field1 int PRIMARY KEY REFERENCES abc(Field1)

    <other fields>

    )

    Creates a PK, and FK on Field1 referencing itself.

    what pupose this type of reference can serve?

    Checked it on SQL Server 7, SP3

    Regards,

  • You can create a recursive table for example an employee has a manager who is also an employee.

    Best regards,

    Klaas-Jan Ruyter

  • hmmm... But in this case can't I use just another field referencing the PK?

    Regards,

  • Kashif you are rigth in what you state as this is a bad way to reference especially the PK since it will be unique. As a friend here would say

    quote:


    There is a flaw in the slaw.


    meaning a reference from a field directly back to itself has no reason for existance. Might want to try SP4 to see if still works then throw a bug report to MS.

    "Don't roll your eyes at me. I will tape them in place." (Teacher on Boston Public)

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply