I am using SQL 2012 and want my CREATE TABLE DDL statements to look something like this:
create table mytable (mypkcol int not null primary key, myfkcol int not null foreign key references myothertable(myothertable_pkcol))
or, for tables with multi-column primary keys, I like to use the syntax:
create table mytable (mypkcol1 int not null, mypkcol2 int not null, myothercol varchar(20) null, primary key (mypkcol1,mypkcol2))
By using this syntax to define table constraints, SQL will auto-create constraint names and I don’t have to manage a naming convention or bother with making sure all my constraint names make sense.
I haven’t been able to figure out a way to do this. I did figure out how to generate the PK inside the create table, but it still wants to use the primary key name to name the PK constraint.
Any tips? Thanks!