Adding a Log file

You sometimes can be called in emergency: A user made a mistake and launched a big batch with wrong parameters and the log file is growing up. You need to react quickly.

First of all check the space used in the log file with the following command:

DBCC SQLPERF(LOGSPACE)

In a second time, analyse the space you have on your disks (local, SAN, externals if necessary) and decide for a location. You can now apply the following script in your SSMS console

ALTER DATABASE DataBaseName 
 ADD LOG FILE
  (NAME = N'DatabaseLogName',
  FILENAME = N'D:\Pathname\DatabaseLogName.ldf',
  SIZE = 512MB,
  FILEGROWTH = 50,
  MAXSIZE=1500
) ;

You will of course set the filegrowth and maxsize parameters regarding your needs. I recommand always setting a maxsize parameter in order to avoid problems on your disk.