Create a database in SQL Server

In SQL Server, database can be used to store the data and execute the queries to display the result. In this tutorial, we will learn how to create a database and run few sample queries and understand how it works. We will create an online store database which is normally used in any ecommerce online store application.

Create a new database

Open SQL Server Management Studio and connect with Database Engine. Once connected, right click on Database option from left object explorer panel and you will see New Database option from dropdown list.

create database in sql server

Once you click on New Database option, following screen will appear where you can add your database name as shown in the following screen. Here, “OnlineStore” we have mentioned as database name and then click on Ok button.

create database in sql server

Now, your database “OnlineStore” will appear on left panel under Database panel shown in following screen.

create database in sql server

Here, we can expand our database by using + icon and it will show more option under database. By using those options we should be able to create database diagrams, create tables, create views, create store procedures, create triggers, create users etc…

We can also create a new database by using a New Query window from top toolbar options. When we click on it, it will open new query window where we can write a SQL command to create a new database.

create database in sql server

Create a database via SQL Command

Example: Create Database
Create Database [Database Name];
Create Database OnlinstStore_1;

Here, we can write SQL command and database name as parameter which will create a new database. Once you write command and database name, you will have to press F+5 from your keyboard or click on “Execute” on tool bar. In the following screen, we have created a new database called “OnlineStore_1” which you can see in database list on left panel under Databases.

create database in sql server

Now your database is setup and we will learn more about how to create a table in SQL Server in coming tutorial.