Categories
SQL Server Step By Step

How To Create Database in SQL Server

How To Create Database in SQL Server

Hi friends in this post, we will learn how to create database in SQL server. We can create database by two ways, in this post we will discuss about both ways in details.

Create Database With SQL Server Management Studio:

1. Login into SQL Server Management Studio.

2. Now right click on Database and click on New Database.

how to create database in SQL server management studio

3. A pop up window will appear, enter database name, Set Owner. In options you can set collation, recovery model, compatibility level etc. In filegroup you can add new filegroup.

 Create Database With SQL Server Management Studio

Create Database With SQL Server Query:

1. Login into SQL Server Management Studio.

2. Click on New Query on tool menu, or press CTRL+N.

Query:

USE MASTER;
GO
CREATE DATABASE TEST
ON 
( NAME = TEST_DB,
    FILENAME = 'C:\PROGRAM FILES\MICROSOFT SQL SERVER\MSSQL11.MSSQLSERVER\MSSQL\DATA\TESTDB.MDF',
    SIZE = 10,
    MAXSIZE = 50,
    FILEGROWTH = 5 )
LOG ON
( NAME = TEST_LOG,
    FILENAME = 'C:\PROGRAM FILES\MICROSOFT SQL SERVER\MSSQL11.MSSQLSERVER\MSSQL\DATA\TESTLOG.LDF',
    SIZE = 5MB,
    MAXSIZE = 25MB,
    FILEGROWTH = 5MB ) ;
GO