When you create a database in SQL Server using the default options, one data file and one log file are created. The data file stores the data and database objects (such as tables, views, stored procedures, etc). The log file stores the information that is required to recover all transactions in the database. If you have a growing database, you may find yourself in the situation where you need to add a new log file (and/or data file).
Just as you can add more data files to an existing database in SQL Server, you can also add more log files. However, the syntax is slightly different depending on whether you’re creating a data file or a log file. Adding a data file requires ADD FILE
while adding a log file requires ADD LOG FILE
.
This article demonstrates how to use T-SQL to add a log file to an existing database in SQL Server.