In this SQL Server tutorial, you will learn how to create a database in SQL Server Management Studio.
The SQL Server Management Studio is a tool or integrated environment provided by Microsoft to manage and work with SQL Server databases.
So, in this tutorial, I will show how to create a database using SQL Server Management Studio. Also, you will learn about the error that occurs while creating the databases.
Finally, you will understand the naming convention you can use for SQL server database names.
Create Database in SQL Server Management Studio
To create a database in SQL Server Management Studio, first make sure you have installed the SQL Server Management Studio. If you haven’t installed it, download it from this link SSMS.
After installing the SQL Server Management Studio, open it.
Create Database in SQL SSMS: Connect to Server Instance
Next, after opening the SQL Server Management Studio, connect to the SQL server instance, which you can see in the below picture.
To connect to the SQL Server instance, you need to provide the configuration that you have specified while installing the SQL Server Management Studio, such as Server type, Server name, and Authentication.
- If you are using a local SQL Server, you can connect to it using Windows Authentication, and for a remote SQL Server, you need to provide credential details with server names or IP addresses.
- So here choose Server type as Database Engine, Server name as hostname\SQL server instance (MSI\SQLExpress), and Authentication as Windows Authentication.
Here, you will see how to connect with a local SQL Server and create a database. So click on the Connect button that you see in the above picture, and you will be connected to the SQL Server instance.
After connecting to the SQL Server instance, you see the Object Explorer on the left side of the SSMS. Object Explorer shows the different nodes or subnodes as tree structures such as Databases, Security, etc.
Create Database in SQL SSMS: Database Node
To create a database in SQL Server Management Studio, right-click on the Database node and select the option ‘New Database’.
After selecting the ‘New Database’ option, a window pops up for the configuration of the new database.
Select the General page from the left side of the window, as you can see in the below picture.
After that, provide the database name, for example, ‘Customer’, and you can also choose the database owner. By default, the database owner is the user who creates a new database in SQL Server Management Studio.
So keep the default owner; if you have a different owner, then select that owner. Then click on the OK button at the bottom right corner to create a database in SQL Server Management Studio.
If you want to configure the new database with advanced settings, then you can choose the pages such as Options and Filegroups.
To view the created database, which is ‘Customer’ in this case, from Object Explorer, expand the Database node by clicking on the ‘+’ icon as shown in the picture below.
In the above picture, you can see the newly created database ‘Customer’ in the Database node section. This is how to create a database in SQL Server Management Studio.
Create Database in SQL SSMS: Existing Database
You need to remember one thing when you are going to create a new database, make sure that the new database name doesn’t already exist.
Let me show you ‘What happens when you create a new database with the same name that already exists in the SQL Server?’.
In the above step, you created a database named ‘Customer’, and let’s create this database again. So right-click on the Database node and select the New Database option.
Then specify the database name as Customer and click on the OK button.
When you click on the OK button, it shows the error in the picture below.
You can see the error ‘Create failed for database Customer’, and the reason for this error is Database Customer already exists. Now you can only create a new database with a different name, or you can connect to an already existing database and continue your work.
But the question is how you can check about already existing databases; for that, you need to expand the Database node section from the Object Explorer panel. you see all the existing databases under that section.
Create Database in SQL SSMS: Naming Conventions
While creating a database in SQL Server, you can use the singular or plural names for the database.
The name of the database depends upon the preference and specific use case. But the question is ‘When to use singular or plural names for the databases’.
- If your database represents a single entity, then use the singular name for your database. For example, in the above steps, you create a ‘Customer’ database, which is going to contain all the customer data.
- If your database represents a set of entities or a collection of entities, then use the plural name, for example, ‘OrdersDatabase’, which can contain multiple orders.
- Always use CamelCase or Underscores to separate the words such as OrdersDatabase or Orders_Database.
- Don’t include spaces and special characters in your database names.
- Don’t use reserved keywords in your database names such as select, table, or database.
Conclusion
In this SQL Server tutorial, you learned how to create a database in SSMS, and also learned how to connect to an SQL Server instance with the required information. For example, you created a database named ‘Customer’. Then, you learned about the error for the already existing database with the naming convention for your SQL server database.
You may also like:
- How to Create a Database in SQL Server Using Query?
- How to Create a Database in SQL Server Using Command Line?
- Change Database Name in SQL Server using Query
- How to Create Database If Not Exists in SQL Server?
- How to Check Database Size in SQL Server Using Query?
After working for more than 15 years in the Software field, especially in Microsoft technologies, I have decided to share my expert knowledge of SQL Server. Check out all the SQL Server and related database tutorials I have shared here. Most of the readers are from countries like the United States of America, the United Kingdom, New Zealand, Australia, Canada, etc. I am also a Microsoft MVP. Check out more here.