SQL Server Create Database

Method 1: Using Graphical User Interface

1. Connect to SQL Server Management Studio.

SQL Server Create Database

2. Once connected, right click on databases, select ‘New Database….’.

SQL Server Create Database

3. Provide the database name, owner of database, physical path file location and auto growth size,Recovery Model type, etc.

SQL Server Create Database2

Initial size will acquire from model database properties, we can change as per our requirements.

4. Click on OK to start database creation. Right click on databases click on Refresh to see the latest database name in the list.

SQL Server Create Database3

Method 2: Using T-SQL

Example:

CREATE DATABASE [k2admindep] ON PRIMARY ( NAME = N'k2admidep', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL12.PRD1\MSSQL\DATA\k2admindep.mdf' , SIZE = 3072KB , MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB ) LOG ON ( NAME = N'k2admindep_log', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL12.PRD1\MSSQL\DATA\k2admindep_log.ldf' , SIZE = 1024KB , MAXSIZE = 2048GB , FILEGROWTH = 10%)

Syntax:

CREATE DATABASE database_name [ CONTAINMENT = { NONE | PARTIAL } ] [ ON [ PRIMARY ] [ ,...n ] [ , [ ,...n ] ] [ LOG ON [ ,...n ] ] ] [ COLLATE collation_name ] [ WITH

Powered by k2schools