CREATE DATABASE using file in default path

Create the database ‘Documents’ and give file properties through an alter.

USE [master]
GO

CREATE DATABASE [Documents]
GO

ALTER DATABASE [Documents] MODIFY FILE
( NAME = N'Documents', SIZE = 512MB, MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB )
GO

ALTER DATABASE [Documents] MODIFY FILE
( NAME = N'Documents_log', SIZE = 256MB, MAXSIZE = UNLIMITED, FILEGROWTH = 10% )
GO

This script is more portable and can be deployed in multiple servers without any modifications.

Leave a Comment