3

A friend has recently started teaching me how to design relational databases. Long story short, as I am not SQL-capable yet, we're using SSMS and lots of right-clicking.

And I am frustrated with the stuff - 95% of the new tables I make have ID as first column (non-nullable INT primary key) and I have to change datatype and mark it as primary each time. So it can be even more frustrating, setting table view to Custom requires roughly the same amount of wasted clicks each time as well (though it is "set as default").

What am I doing wrong? Said friend does his part mostly in the code editor (or whatever is the name of the actual feature) and doesn't know the GUI that well.

Is there any way to automate these first steps for new tables? Get them done with only "create table"-click and filling in the name field preferably?

Sorry for my bad English (but I searched through other questions first ;)).

1 Answer 1

1

I'm not sure you can automate this in SSMS. Why not take the opportunity to learn a little SQL? The script below will create a table with ID as the primary key (int) - you can then just add the extra columns you need (refresh your table list first):

CREATE TABLE [dbo].[your_table_name](
[ID] [int] NOT NULL,
CONSTRAINT [PK_your_table_name] PRIMARY KEY CLUSTERED 
(
   [ID] ASC
))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.