By: Armando Prato
Overview
We've created a table but it needs a primary key. Also, we could use some stored procedures to access the data we add to the table.
Explanation
Adding additional objects is just as easy as what we went through to add our table. Let's add a primary key to the table we just created.
In the Schema View, right click Keys under the table we just created. The option to Add a primary key will appear:
Clicking on Primary Key... again presents the Add New Item screen. The Name field will default to some value. We change this value to PK_FootBallClub and click Add:
A script window will again appear with a template script. We change the template code as follows to match the primary key we want to maintain.
Saving the changes, the Schema View will show the primary key under Keys for the table.
Creating stored procedures are also a snap. Again under Schema View, we right click on Stored Procedures under Programmability and choose Stored Procedure...
Again, the Add New Item appears and we create our first stored procedure
A template screen with a default template code for your procedure will appear. We change the template code as follows to define our procedure:
Repeating the steps we went through for the 1st procedure, we create a 2nd procedure which is a child procedure to the first procedure we created
Last Update: 9/10/2011