Could not allocate space for object ' * ' in database ' * ' because filegroup ' PRIMARY ' is full

Source: Internet
Author: User
Tags filegroup

The server uses mssqlserver2005, the recent often can not add information error, view the log, found a serious error prompt, the content is roughly:

The object ' dbo.wx_logs ' in database ' Weixin_main ' could not be '. ' pk_wx_logs_id ' allocates space because the ' PRIMARY ' filegroup is full. Please delete unwanted files, delete objects from filegroups, add additional files to filegroups, or enable autogrow for existing files in filegroups to increase free disk space.

Open Enterprise Manager, right-click on the error database, select "Properties", Pop-up dialog box, found that the General tab of the free space display only 1.03M, the original problem is here, think of the previous restrictions.
A solution at this point is to set the database file and the maximum file size for the log to be unrestricted for file growth.
Note to frequently clean up database logs and to back up database files.


The following related content is collated for reference only

Tip: For this issue, whether the primary check limits the database file growth
1. Check that your disk is free of space, clean up the disk if there is no disk space left, make room
2. Check your disk partition format
If it is FAT16, the data file can only be 2G, if it is FAT32, the data file can only be 4G, the NTFS partition is not the limit
3. Check to see if you have limited database file size
Enterprise Manager--right--Your database--Properties--File growth limit--if there is a limit size, remove the limit
4. Check your SQL version, if you are using MSDE, limit the data file to 2G max.
5. You can also add a new data file for the primary group to solve this problem
ALTER DATABASE name add file (name = logical file name, filename = c: Actual file name. ndf
Also, be aware of the space usage of tempdb! The staging database should be cleaned up frequently!

Ways to clean up logs

When the SQL database log file is full, you can cancel the log file size limit, and of course we prefer to compress it periodically to clear the useless records from N days ago
Provides a way to compress logs and database files as follows:
1. Clear the Log
DUMP TRANSACTION Library name with NO_LOG
2. Truncate the transaction log:
BACKUP LOG database name with NO_LOG
3. Shrink the database file (if not compressed, the database file does not decrease
Enterprise Manager--right-click the database you want to compress--all tasks--shrink the database--Shrink the file
--Select Log file--select shrink to XXM in the shrink mode, here will give an allowable shrinkage to the minimum m number, directly enter this number, OK.
--Select the data file--choose Shrink to XXM in the contraction mode, here will give a allowable shrinkage to the minimum m number, directly enter this number, OK.
You can also use SQL statements to complete
--Shrinking database
DBCC shrinkdatabase (Customer profile)
--Shrink the specified data file, 1 is the file number, which can be queried by this statement: SELECT * from Sysfiles
DBCC Shrinkfile (1)
4. In order to minimize the log file (if SQL 7.0, this step can only be done in Query Analyzer)
A. Detach the database:
Enterprise Manager--server--database--right--detach database
B. Delete the log file from My Computer
C. Additional databases:
Enterprise Manager--server--database--right--Attach Database
This method will generate a new log with a size of only more than 500 k
or in code:
The following example detaches pubs and then attaches a file in pubs to the current server.
A. Separation
E X e C sp_detach_db @dbname = pubs
B. Deleting a log file
C. Re-attach
E X e C sp_attach_single_file_db @dbname = pubs,
@physname = C:Program FilesMicrosoft SQL servermssqldatapubs.mdf
5. In order to automatically shrink in the future, do the following settings:
Enterprise Manager--server--right-click Database-Properties--Options--select "Auto Shrink"
--sql Statement Setup Method:
E X e C sp_dboption database name, autoshrink, TRUE
6. If you want to not let it grow too large in the future
Enterprise Manager--server--right-click Database--Properties--transaction log
--Limit file growth to XM (x is the largest data file size you allow)
How to set the--sql statement:
ALTER DATABASE name modify file (name= logical file name, maxsize=20)
Special attention:
Please follow the steps, do not take the previous steps, please do not follow the steps
Failure to do so may damage your database.
Generally not recommended to do 4th, 62 steps
The 4th step is unsafe, potentially damaging the database or losing data
6th step if the log reaches the upper limit, subsequent database processing will fail and cannot be resumed until the log is cleaned up.

A more straightforward workaround:
1. Right-built Database Properties window--Fault restore model--set as simple
2, right-built database All tasks-shrinking database
3. Right-built Database Properties window--Fault restore model--set as bulk-logged

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.