Microsoft SQL Server - create database using transact sql (mdf ldf)

by
Jeremy Canfield |
Updated: April 26 2023
| Microsoft SQL Server articles
The create database command can be used to create a new database. In this example, a database named foo is created. Notice two files are created, foo.mdf (Main Data File) and foo.ldf (Log Data File). The Main Data File contains all of the information about the foo database and the Log Data File logs all transactions and changes made to the database.
CREATE DATABASE foo
ON
( NAME = foo_data,
FILENAME = 'Z:\path\to\foo.mdf',
SIZE = 10MB,
MAXSIZE = 50MB,
FILEGROWTH = 5MB )
LOG ON
( NAME = foo_log,
FILENAME = 'Z:\path\to\foo.ldf',
SIZE = 5MB,
MAXSIZE = 25MB,
FILEGROWTH = 5MB ) ;
Did you find this article helpful?
If so, consider buying me a coffee over at