Wednesday, 11 March 2020

MSSQL SERVER database creation script with specified size and growth

USE master
GO

CREATE DATABASE [Prod]
 CONTAINMENT = NONE
 ON  PRIMARY
( NAME = N'Prod',
FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL14.SMRPLM\MSSQL\DATA\Prod.mdf' , --<< this must be in its own physical drive
SIZE = 5MB , --<< pre size the data file 5000 mb
FILEGROWTH = 1MB )  --<< pre size the log file 100 mb

 LOG ON
( NAME = N'Prod_log',
FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL14.SMRPLM\MSSQL\DATA\Prod.ldf' , --<< this must be in its own physical drive
SIZE = 1MB , --<< pre size size of transaction log file 100 mb
FILEGROWTH = 1MB ) --<< pre size size auto growth to increase in increments of 5 mb
GO

No comments:

Post a Comment