Create a Database by Script

SQL Server accepts Transact-SQL (which is an extended version of the SQL standard), so you could create the database by running the following SQL script.

USE master;
GO
CREATE DATABASE Music;
GO

To do this, open a new query by clicking New Query in the toolbar and run an SQL CREATE DATABASE statement.

Just as you can specify certain properties when creating a database via the GUI, you can include those same properties when creating a database by script. Here’s an example of specifying settings for the data and log files.

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

About sqlschool

SQL School (Regd: SequelGate Innovative Technologies Pvt. Ltd.) is one of fastest growing organization delivering Realtime Training and Realtime Projects exclusively on Microsoft SQL Server. Our Training services include SQL DBA Online Training, MSBI Online Training, SQL DBA Classroom Training, MSBI Classroom Training and Realtime Projects. SQL School, established in February, 2008 is now, one of the best institute offering Trainings on SQL Server, SQL Database Administration (DBA) and Business Intelligence (BI) technologies. We have been working with numerous consultancies in India, US, UK and Australia. We undertake Online Trainings and Corporate Trainings on SQL Server 2008, SQL Server 2008 R2 and SQL Server 2012 (DENALI) versions. We make sure that all our sessions are very much interactive and well structured. We encourage every participant to come up with his / her own queries during & after the training sessions. We prefer practical approach rather than theoretical information to master the technical depth of the technology. We provide excellent Lab Handouts for practice, Realtime Case Studies and Projects on SQL Server Administration (SQL DBA) and Microsoft Business Intelligence (MS BI) Training courses. Free LIVE DEMOs would be provided prior to training registration. Specific DAY to DAY Course Plan will also be shared prior to training registration to ensure transparency of our Training services.