I’m in the process of learning SQL and in so doing have started learning Microsoft SQL using Microsoft’s SQL Management Studio. It’s a free program that’s used to open, manage, and edit Microsoft SQL databases stored on a server running Microsoft SQL (quick note: SQL is a database language used to store data in tables that can be accessed from programs or websites).
When you first load the program (I’m running SQL Server 2005, which is not free), if you haven’t already opened a database, it will prompt you to connect to one. If or once connected to a database, it will appear in the left menu.
The places you’ll be working in the most are under the “Database” folder: Tables, Views, and Programmability > Stored Procedures. For this post I will be focusing on Tables and specifically, creating Primary Keys.
Table Best Practices
To create a table, right-click on the Tables folder and select “New Table”. SQL will automatically append a “.dbo” to the front of the table name, but to keep things clear later on, add your own “tbl” or something similar to the beginning of a table name.
Once you have created a table, create a new column to use as a primary key, then change the type to INT for integer. This will create a way to identify rows that are unique to the table, which allows all sorts of other functions to work correctly later on.