I am creating a table, how can I set the primary key for my table without using my mouse? I want to do this using my keyboard (short key).
Try using: Alt + L , Y (case insensitive).
This key combination will be marked as PrimaryKey selected column (in development mode).
PrimaryKey
Here is an example:
CREATE TABLE Persons ( P_Id int NOT NULL, LastName varchar(255) NOT NULL, FirstName varchar(255), Address varchar(255), City varchar(255), PRIMARY KEY (P_Id) )
P_Id is a column with a primary key constraint .
Like this:
ALTER TABLE Persons ADD PRIMARY KEY (P_Id);
then you press CTRL + E
Question: what is a shortcut key?
And I do not think that Sql Management Studio has a keyboard shortcut to add a Primary Key to the table. I am also sure that you cannot find a shortcut for the Set primary key menu item.
Not 100% sure you can do this, but here is a list of keyboard shortcuts for Sql Server Management Studio.
Perhaps you could create your own .
You can install SSMS Tools and create your own piece of code.