How to Create Database in SQL Server– Learn to create MS SQL Server Database using SQL Server Management Studio. You can also write a script to create a new database. To create a database you should have the privilege. So make sure that you have the privilege. In MS SQL Server the default use is “sa” which is a system admin user and the system admin user has all privileges. Therefore if you go with “sa” user then you got the all privileges.

Table of Contents

  1. What is Database?
  2. Create a Database in SQL Server Management Studio.
  3. Write a script to create a database in SQL Server.

What is Database?

In the case, of information technology data is to store digitally. Therefore data is to store in the electronic storage device. Database is the application software which manages the digital data. Database system helps to store digital data with indexing and organised way also easily read data when need it.

In this article, we discuss the process of creating a database in MS SQL Server. MS SQL Server is the famous Database Management System by Microsoft.

Create a Database in SQL Server Management Studio.

SQL Server Management Studio is a tool to manage MS SQL Server. Therefore you can create Databases with this tool easily. To create a database follow the following steps.

Step 1: Connect SQL Server SQL Server Management Studio.

SQL Server Management Studio connect with SQL Server
Connect With SQL Server

Open SQL Server Management Studio then click on the “Connect” button then find the database under Database Engine. After selecting the database click on the “OK”. Also you can type the Database Instance name in the “Server Name” field.

SQL Server Authentication system

In the case of MS SQL Server two types of Authentication mode available one is “Windows Authentication” and other is “SQL Server Authentication“. So if the “Windows Authentication” enabled in the SQL Server then you can log in the Database Server otherwise you need to log in with “SQL Server Authentication Mode“. Windows authentication can access only from the local computer. So to access the Database from the network you need “SQL Server Authentication Mode”

In the case of “SQL Server Authentication” you need a user name and password. “sa” is the default system admin user of SQL Server. To enable the authentication system you should enable the “Mixed Mode Authentication” at the time of installation or you can enable it from “Security” tab under “Server Properties” window.

Create SQL Server Database
Create New SQL Server Database

After connecting SQL Server with Management Studio Right Click on Database under tree view and click on “New Database“. Then you will get a New Database window where you have to enter the name of the database. If you want to change the directory of database’s files then you can change it from the “New Database” window. See the screenshot below. After enter and the name of the database and all configuration just click on OK.

Enter database name and data directory
Enter database name and data directory

This is a very simple process to create a database with a graphical user interface. But there is also a process to create a database.

Write a script to Create Database in SQL Server.

Another popular way to create a new database is executing the database creation script. To open new query window just click on “New Query” option from SQL Server Management Studio or press “Ctrl+N” then write the script for creating a database. After write just click on “Execute” option or press “F5” to execute the script. See the basic syntax to create a database.

USE master ;  
GO  
CREATE DATABASE MyDemoDB
ON   
( NAME = MyDemoDB,  
    FILENAME = 'C:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\DATA\MyDemoDB.mdf',  
    SIZE = 10,  
    MAXSIZE = 50,  
    FILEGROWTH = 5 )  
LOG ON  
( NAME = MyDemoDB_log,  
    FILENAME = 'C:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\DATA\MyDemoDB_log.ldf',  
    SIZE = 5MB,  
    MAXSIZE = 25MB,  
    FILEGROWTH = 5MB ) ;  
GO  

But you can create a database with the following simple script. The simple script will create a database with the default file name in the default data directory of SQL Server

Simple script to Create Database in SQL Server.

CREATE DATABASE MyDemoDB

But if you want to specify the file path then you need to mention the name of the files and the directory path.

The script to create a database with the custom file name and directory location.

USE [master]
GO

CREATE DATABASE [MyDemoDB] ON  PRIMARY 
( NAME = N'AdventureWorks_Data', 
	FILENAME = N'D:\SQL_Data\MyDemoDB_Data.mdf' , 
	SIZE = 167872KB , MAXSIZE = UNLIMITED, FILEGROWTH = 16384KB )
LOG ON 
( NAME = N'AdventureWorks_Log', 
	FILENAME = N'D:\SQL_Data\MyDemoDB_Log.ldf' , 
	SIZE = 2048KB , MAXSIZE = 2048GB , FILEGROWTH = 16384KB )
GO

After creating the database you need to execute the following script to use the database.

USE DATABASE MyDemoDB

Create Database in SQL Server
Create Database in SQL Server

This Post Has 36 Comments

  1. zoritoler imol

    It’s arduous to seek out educated folks on this subject, but you sound like you realize what you’re speaking about! Thanks

  2. curso de home office com certificado

    Wow, marvelous blog structure! How long have you been running a blog for? you make blogging look easy. The full glance of your site is great, as well as the content material!

  3. curso de pilotagem fórmula 1

    Nice post. I was checking continuously this blog and I’m impressed! Very helpful info particularly the last part 🙂 I care for such information a lot. I was seeking this particular info for a long time. Thank you and best of luck.

  4. Curso Formação em Cftv Circuito Fechado de Televisão Eduk

    The things i have observed in terms of laptop memory is the fact that there are specific features such as SDRAM, DDR or anything else, that must fit the technical specs of the mother board. If the personal computer’s motherboard is reasonably current and there are no operating-system issues, modernizing the ram literally normally takes under one hour. It’s among the easiest personal computer upgrade methods one can imagine. Thanks for revealing your ideas.

  5. curso concursos rateio

    I was recommended this blog by my cousin. I am not sure whether this post is written by him as no one else know such detailed about my problem. You’re amazing! Thanks!

  6. Js Adil Ahmed

    Thanks for the different tips discussed on this site. I have observed that many insurance companies offer buyers generous special discounts if they choose to insure a few cars with them. A significant quantity of households currently have several autos these days, particularly those with more aged teenage youngsters still located at home, as well as the savings for policies could soon begin. So it makes sense to look for a good deal.

  7. rummy game

    I like the helpful info you supply to your articles. I?ll bookmark your blog and check once more right here regularly. I’m moderately sure I?ll be informed lots of new stuff proper here! Best of luck for the following!

  8. Tuning Mysql Server 5.1 e 5.6 Oys

    I do like the manner in which you have presented this specific challenge plus it does indeed supply us some fodder for consideration. Nonetheless, because of everything that I have witnessed, I just trust as other reviews pack on that men and women keep on point and in no way get started upon a tirade involving the news of the day. Anyway, thank you for this superb point and whilst I can not necessarily concur with this in totality, I value the viewpoint.

  9. Curso de Cervejas Artesanais Marcelo Mensch

    Thanks for the tips you have shared here. In addition, I believe there are numerous factors which really keep your car insurance premium straight down. One is, to take into consideration buying motors that are in the good set of car insurance firms. Cars that happen to be expensive tend to be more at risk of being robbed. Aside from that insurance coverage is also depending on the value of your car, so the higher priced it is, then the higher the actual premium you make payment for.

  10. Cookies Faça e Venda Juliana Abbud Eduk

    I like the helpful info you provide in your articles. I will bookmark your weblog and check again here frequently. I’m quite sure I?ll learn lots of new stuff right here! Good luck for the next!

  11. vorbelutrioperbir

    I really like your writing style, great information, thank you for putting up :D. “Inquiry is fatal to certainty.” by Will Durant.

  12. Albert Fang

    My brother suggested I might like this website. He was once entirely right. This submit truly made my day. You can not believe just how so much time I had spent for this info! Thank you!

  13. supersplit online casino

    Wow, superb blog format! How lengthy have you ever been running a blog for? you made blogging look easy. The entire glance of your web site is excellent, as smartly as the content!

  14. Ikaria juice

    Hi, i think that i saw you visited my site so i came to ?return the favor?.I’m attempting to find things to enhance my website!I suppose its ok to use a few of your ideas!!

  15. Most Expensive Sex Doll

    Pretty nice post. I just stumbled upon your blog and wanted to say that I’ve really enjoyed surfing around your blog posts. In any case I will be subscribing to your feed and I hope you write again soon!

  16. curso mecânica automotiva presencial

    Hello there, You’ve performed a fantastic job. I will certainly digg it and in my view recommend to my friends. I’m confident they’ll be benefited from this site.

  17. Joanne Hirn

    Please provide me with more details on the topic

  18. Aleisha Kordas

    Thank you for writing such a great article. It helped me a lot and I love the subject.

  19. gralion torile

    Howdy! I’m at work browsing your blog from my new iphone 3gs! Just wanted to say I love reading through your blog and look forward to all your posts! Carry on the excellent work!

  20. zoritoler imol

    Hi my friend! I want to say that this article is amazing, great written and include almost all important infos. I?¦d like to see more posts like this .

  21. zoritoler imol

    I love it when people come together and share opinions, great blog, keep it up.

  22. zoritoler imol

    You have observed very interesting points! ps decent website.

  23. zortilonrel

    I simply could not depart your site prior to suggesting that I extremely loved the standard info a person provide to your guests? Is gonna be back regularly to check up on new posts

  24. buy cialis online with a prescription

    It’s hard to find educated people on this topic, however, you sound like you know what you’re talking about!
    Thanks

  25. Agen338

    I think this is a real great article post.Thanks Again. Really Cool.

  26. zortilo nrel

    Woah! I’m really digging the template/theme of this site. It’s simple, yet effective. A lot of times it’s very hard to get that “perfect balance” between user friendliness and visual appeal. I must say you’ve done a fantastic job with this. In addition, the blog loads very fast for me on Chrome. Outstanding Blog!

  27. manhwaland

    Very good blog post.Really thank you!

  28. zortilo nrel

    My brother suggested I might like this blog. He was entirely right. This post actually made my day. You can not imagine just how much time I had spent for this info! Thanks!

  29. zortilonrel

    Thanks for the sensible critique. Me & my neighbor were just preparing to do some research about this. We got a grab a book from our local library but I think I learned more from this post. I’m very glad to see such wonderful information being shared freely out there.

  30. 0mniartist

    Hi, this weekend is good designed for me, as this occasion i am reading this wonderful informative post here at my residence.
    0mniartist asmr

  31. download

    Great post! We are linking to this great post on our site. Keep up the good writing. Nanette Hillier Mosera

  32. erotik

    Excellent, what a blog it is! This web site presents valuable data to us, keep it up. Marysa Boycey Erskine

  33. bahis

    Wonderful post! We will be linking to this particularly great article on our site. Keep up the good writing. Chere Donovan Carthy

  34. erotik

    Every once in a even though we choose blogs that we read. Listed below would be the newest web sites that we decide on. Hayley Leonhard Sale

  35. sikis

    No matter which genre you a bit more complicated than that. Elladine Kimble Drus

  36. sikis

    I truly appreciate this article. Much thanks again. Carolin Dwight Silvanus

Leave a Reply