• Sean Lange (1/29/2013)


    It seems that today's QOTD fits in nicely with this discussion. A very simple method was presented there using a constraint to allow a table to have only 1 row.

    CREATE TABLE Test_Table (PK BIT PRIMARY KEY, Comment VARCHAR(10));

    ALTER TABLE Test_Table ADD CONSTRAINT PK_check CHECK (PK <> 0);

    That is about as simple as you can make it.

    I think CREATE TABLE Test_Table (PK BIT PRIMARY KEY CHECK(PK <> 0), Comment VARCHAR(10));does the same thing and is easier to read. Of course it doesn't provide a user-specified name for the check constraint, but ....

    Tom