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

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 ) ;

 



Add a Comment




We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.




Please enter 4b57d in the box below so that we can be sure you are a human.




Comments

Web design by yours truely - me, myself, and I   |   jeremy.canfield@freekb.net   |