Kwizcom Forms

Create a database by command in sql server 2008

In this post, we will discuss how to create a database by using the command in sql server 2008. Also, you can check my previous posts on:

Data files and Log files in sql server 2008

SharePoint deveopment training course

Error functions in sql server

Show hide div using jQuery in

To create a database sql server provides create database command that has the following syntax.

Create database <dbname>

When you create a database using the above syntax one data file and one log file is automatically created for the database in the default location of sql server i.e, C:\program files\Microsoft SQL server\MSSQL 10.MSSQL SERVER\MSSQL\DATA

Sql server provides a stored procedure named sp_helpdb that takes database name as an argument and returns details of that database like datafile and logfile created for it and memory allocated for those files.
Ex: sp_helpdb’DB1’

To create a database by specifying datafile and logfile specification manual, use the following syntax.

Create database <dbname>
On(<datafile specification>)
Logon(<logfile specification>)

create database DB
on (name=db_dat,filename=’d:\db_dat.mdf’,size=4,filegrowth=2,maxsize=unlimited)
logon(name=db_log,filename=’d:\db_log.ldf’,size=2,file growth=1,maxsize=300)

Creating a database in GUI:

To create a database in GUI below are the steps.
Within Object Explorer right click on the “databases” category and choose a new database that opens “new database” dialog box.

Then within the dialog box provide a database name which will automatically create one data file and one log file with default specifications, which you can modify.

After making the required changes to the specification of the files click on “Ok” button to complete creating a database.

Check out Best Alternative to InfoPath -> Try Now

free sharepoint training

SharePoint Online FREE Training

JOIN a FREE SharePoint Video Course (3 Part Video Series)


About Bijay Kumar

I am Bijay from Odisha, India. Currently working in my own venture TSInfo Technologies in Bangalore, India. I am Microsoft Office Servers and Services (SharePoint) MVP (5 times). I works in SharePoint 2016/2013/2010, SharePoint Online Office 365 etc. Check out My MVP Profile.. I also run popular SharePoint web site

View all posts by Bijay Kumar →