How to Create a Database in SQL Server 2008 R2

This tutorial will show how to create a database in SQL Server 2008 R2. Think of a database as a container of objects such as tables, views, stored procedures, and so on. There are four system databases that the setup program creates: master, model, msdb, and tempdb. Though, after installation we are able to create our own user databases that will hold program data, which is what we will do. We will create a database that will be able to create tables and hold data.

Step One

Open Microsoft SQL Server Management Studio and connect to a Database Engine.

The server name will be the computer name followed by “SQLEXPRESS”, for example your Server name will be ‘YOUR_COMPUTER_NAMESQLEXPRESS’. Since we are also not connecting to a server, use “Windows Authentication” for the Authentication to use your local login information. Connect to the database engine to continue.

Step Two

If you look in the object explorer and expand the Databases folder, you will see only a System Databases folder. When we create a database, it will appear in this folder and we will be able to modify changes to it, but for now we cannot.

Click the ‘New Query’ button to open a query window to begin creating a database. Creating a database is very simple, we simply use the CREATE DATABASE statement, specify the database name and execute the query.



We called the CREATE DATABASE statement and then specified the database name, which in this case is Sports.

If you look back in the object explorer, you will now see the Sports database that we created. Creating a database is easily done in a single query. Creating databases and creating tables inside of them make the database more organized as opposed to just creating tables in SQL Server Compact.

Thanks for reading and make sure to download the source files to get a better understanding of how the code works.

Leave a Reply

Your email address will not be published. Required fields are marked *