Name the Primary Keys Constraints in the SQL Server model!

Mar 30, 2010 at 8:53 PM

Folks,


Great to have more demo and sample databases for SQL Server - but by all means, name the primary key constraints!!

So instead of

CREATE TABLE Genre
(
    GenreId INTEGER NOT NULL IDENTITY,
    Name NVARCHAR(120),
    PRIMARY KEY(GenreId)
);

which gives you a primary key constraint of something like:    PK__Genre__0385057E1332DBDC      (yuck!!)

please do use

CREATE TABLE Genre
(
    GenreId INTEGER NOT NULL IDENTITY,
    Name NVARCHAR(120),
    CONSTRAINT PK_Genre PRIMARY KEY(GenreId)
);

which gives you a nice, clear, dependable and nicely named PK constraint name!

Coordinator
Mar 30, 2010 at 9:41 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Coordinator
Mar 30, 2010 at 9:44 PM

Thanks for the suggestion. I created a working item for it so I can fix it.

 

Coordinator
Nov 10, 2010 at 7:59 AM

This request has been implemented in the latest Release 1.2.