Please refer to the following steps to set the database size limit for Microsoft SQL Server.
Using SQL Management Studio
- Login to your SQL Management Studio.
- Right-click on the database for which you want to set the limit and click on properties.
- At the database properties dialogue box, click on the files.
- Here, you will find a button called Autogrowth / maxsize. Click on it.
- It will open a dialogue box with the name change Autogrowth for the database.
- Tick on Enable Auto Growth option. Inside Maximum File Size, check the radio button and set the maximum size you want to set for the same database.
Using SQL Query
- Connect to your Database Engine and click on the New Query.
- Run the below query and change your database and database file name.
USE master; GO ALTER DATABASE your_db_name MODIFY FILE (NAME = db_file_name, SIZE = 50MB); GO
- You can run the below query to find the file name of your database.
USE MyDataBase
SELECT name
FROM sys.database_files
WHERE type_desc = ‘ROWS’;
GO