Sql-server – Could not allocate space for object sql server

sql server

Can anyone give a solution for this error:

Could not allocate space for object ‘object_name’ in database ‘database_name’ because the ‘PRIMARY’ filegroup is full. Create disk space by deleting unneeded files, dropping objects in the filegroup, adding additional files to the filegroup, or setting autogrowth on for existing files in the filegroup.

How can I delete files from primary file group?

Best Answer

You need to do one or more of 3 things:

  1. Increase the max file size of the file
  2. Increase the disk space wherever your .mdf & .ndf files are stored
  3. Delete data from your database to free up space for the new object

Right click on your Database > Properties > Files.

Here you will see the file names, file groups, path, and importantly the Autogrowth / Maxsize. If you have it set to Limited to ... then it can't grow beyond this limit. If the file is full, you will either need to change the Maxsize or delete data from your database. If the file isn't full, then your disk could is almost certainly full and you'll need to add space there.

Also, don't shrink your database in an attempt to fix this.