How to Increase the File Size of a Data File in SQL Server (T-SQL)

If you’re using the SQL Server Management Studio GUI, you can increase the size of a data file by right-clicking on the relevant database, selecting Properties, selecting Files under Database Properties, then increasing the value in the Initial Size (MB) column for the applicable data file.

If you’re using Transact-SQL however, you can increase the data file’s size by using the ALTER DATABASE statement with the MODIFY FILE argument. The following example demonstrates how to do this.

Example

Here’s an example that increases the file size of a data file called Solutions_dat_2:

USE master;  
GO

ALTER DATABASE Solutions   
MODIFY FILE  
(
  NAME = Solutions_dat_2,  
  SIZE = 50MB
  );  
GO

First, we change to the master database. Then we use the ALTER DATABASE statement with the MODIFY FILE argument to specify which file to change, and the size that we want to make it.