There are two methods to create an SQL database in MS SQL Server:
-
Using SSMS Framework
- Using Queries
Steps to create a database using SQL Server Management Studio (SSMS) Framework:-
• First launch SSMS Framework.
• On SSMS's home page, you will see a dialog box, "Connect to Server."
• Click the Connect option to connect to an instance of the SQL Server Database Engine.
- Under the Object Explorer window, expand the Instance (Databases).
- Right-click on Databases, and then select the New Database option.
- In the New Database window, give the name of the database in the Database name field. For instance Test Database
- If you want to create the database by accepting all default values, then click OK; otherwise, you can follow the additional steps as required.
- Expand the newly created database (TestDatabase) to create table in it.
- Go to Tables, right-click on it, select New>Table.
- Enter column name, data types, allow nulls (if required) into “Column Name”, “Data Type" and “Allow Nulls” fields.
- Click on Save icon as shown below:
- The Choose Name dialog box is displayed. Give a name for the table, and then click OK.
How to Create SQL Database using queries?
- In SSMS, in Object Explorer, connect to an instance of the SQL Server Database Engine.
- Expand that instance, right-click on the Instance name, and then click New Query.
- Under the Query window, write the below query to create a database in MSSQL.
Create database New2Database; where New2Database is the Database name.
- Click Execute option or press F5 to run the query.
- Next, type the below query
use New2Database
- Click Execute option/ press F5 to run the query.
- Next, create a table in the database using the command below.
create table New1Database(id int,name varchar(90))
- Click Execute option or F5 to run the query.
Your Database with a table and columns has been created as shown below:
These steps result in the successful creation of a database named "New2Database" with a table named "New1Database," containing columns "id" and "name."
The KB provides a comprehensive guide for users to create MS SQL Server databases using both graphical and query-based methods.