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 ;)).

asked Sep 29, 2015 at 9:24

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
))
answered Sep 29, 2015 at 10:35

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.