Create a table in SQL Server Management Studio (SSMS)


In this lesson, we will learn how to create a table in SQL Server Management Studio (SSMS).

Hello, and welcome to this introduction about SQL Server. I’ll be taking you through this course. So, what we’re going to do.First of all we’re going to find and download and instal a free version of SQL Server so you can play with it on your own computer.We’re going to open up a programme called SSMS, that’s Management Services and we’re going to create a database,create a table,insert some dataand retrieve that data.

We’re then going to look at the individual components of SQL Server. T-SQL, Database Administration, or DBA,SSIS, that’s SQL Server Integration Services,SSAS, that’s Analysis Services,and SSRS, that’s Reporting Services. And we’re going to have a look at some resources that can help you learn it.Books, videos and practise tests. We’ll also have a look at the official Microsoft website. So, let’s start.

Right, so the next thing we’re going to do,is we’re going to create a table.So a table stores data.So what sort of table am I going to create? Well, what I’m going to do, I’ve got some previously created data here,and this is a purchase system.So in my purchase number one,I bought four of product number one at a cost of $50.26, totaling $201.04. My purchase order two, then I bought three numbers;359, and three of 360’s and so forth.So it is a perfectly ordinary transaction table.So I’m going to create it.I’m going to leave it on screen,so we can have a look at it while we create the table.

So to create the table, I’m going to right and click on tables and go New >Table. Again, there’s an awful lot of details that we can look at, but we’re just going to look at very simplistic, very easy to create things. So click new table, and here it says,well what columns are you going to create? So I want a column called purchase order ID, and I want another one called order quantity. I want product ID,unit price,and line total.

create-a-table-SQL-Server create-table-SQL

Now there is another thing that we have to specify at the same time. What type of column is it? Or more accurately, what sort of data do you want to store in the column? Now you can see that we got various choices,including,dates,time,text, though in reality, the one that I use the most of the time is called varchar, A variable character. And then we got things like integer.

Integers are whole numbers like one, two, three,instead of 1 1/2.So this is when we really need to look at the data that we got and decide what sort of column we want. And hopefully you can see that the first three columns can all be integers. They’re all whole numbers.  So let’s change them to ints, I-N-T.Now these last two contain–well money, essentially.  And so what I’m going to do is, Int would not be good enough, because if I put $50.26 into an int column, then it will truncate it to $50.

So I would have a certain lack of accuracy. So instead, what I’m going to do, with all of these, is I’m going to put it into the money data type. Though many other different types I could use, but just for now we’re going to use Int for integers and Money for–floating point numbers.  So now I’ve created it, I’ll press– Well what do I do? Well, I can press the Save Table here, or I can close this window.

So let’s click Save, either way we’ll get this choose a name. So what name am I going to call this?I’m going to call this, Transactions.So click okay, and close this, and we’ll go back to our object explorer,and you can see that the Transactions table is, where, exactly?Now, one of the things about object explorer,is that it doesn’t automatically update after you have created a new object. The only exception for this is a database that you have created or attached.


So, if you’ve created a new object,be it a table, a view, a procedure, or anything else,and you want it to appear,they would need to click on the Refresh icon. So now we can see that we have our Transactions table. D-B-O, Databaseowner.Transactions.Every table with have something before this dot, and that is called a schema. But, in this case, it doesn’t really matter what the schema is. So, in the next video, we’re going to populate it, we’re going to add some data to this table, and then we’re going to retrieve it.



Please enter your comment!
Please enter your name here