Last week a user asked my help on this error. After helping him, I thought it would be a good idea if I can post more detailed steps as a blog.
What is the issue?
You receive an error message “Could not allocate space for object dbo.final in database LSWB because the ‘PRIMARY’ filegroup is full. contd….. ” as shown in below pic. You see this error message if you are actively running a transaction from a query window in SSMS or you would see an entry in SQL Server Error Log.
What this error means is, the filegroup mentioned in the error message is full and no more free space is available in the data file(s) of that filegroup. The database objects which need additional space to grow (to add new data) cannot grow causing failure to add new data or if new database object(s) are to be created, that cannot happen due to lack of free space in the filegroup.
Why does this happen?
There might be multiple reasons that cause this problem. Some of them are..
- Autogrowth is not enabled on the file(s) inside the filegroup.
- Autogrowth is enabled on the data files but there is no free disk space to for the data files to grow.
- Autogrowth is enabled on the data file but hit the Max growth size value.
How to solve this?
I order to solve this problem, there are few solutions and which one of the solutions can be applied depends on one or more factors on your SQL Server where this error has occurred.
- If there is disk space available but the data files autogrowth is disabled, then enable autogrowth.
- If there is disk space available and the data files autogrowth is enabled, change the Max file size value to a larger value.
- If the data file can no longer grow due to no free disk space on that drive, then add another data file in that file group on a different drive.
- If the data file can no longer grow due to no free disk space on that drive, and there are no additional drives to add a data file, then you have very few options left. You can try one of the following.
- Delete / move any files (from windows explorer) which reside on that drive to get free space.
- Shrink any other databases that are residing on that drive, may be one of the data files.
- Drop one or more database objects that belong to the same filegroup.
Note: Pay attention when doing either of the last 3 steps, make sure that file(s) are not required (if deleting) or the database you shrink has sufficient free space in itself to survive until you get more oxygen (new storage attached to the server) or the table(s) or Indexes you drop in the same file group are not required any more…
Do you like this site? Like our FB page @ Facebook.com\LearnSQLWithBru so that, you know when there is a new blog post.
— Bru Medishetty
What would happen if a program tries to write data to the SQL Server database, while the HDD is full?
Would the SQL Server try to run Insert statement, and then discard the data?
Yes, SQL Server will try to insert the data and when inserting that data, if SQL does not have enough free space inside the data files, it will try to grow as per the autogrow settings (if enabled) and will fail as there is no disk space available…
Very good explanation! Simple and to the point, just the way I like it.
same issue in web server sql database