primary filegroup full - sql-server

I discovered an error in a log file while troubleshooting another issue on our SQL 2000 server. I am seeing primary filegroup is full. The MDF and LDF files are in the default location on the system partition, on an NTFS drive. The MDF file is 1962MB in size. Some posts have indicated that the size can't excede 2GB. I ran a db shrinkdatabase against it but it does not appear to have changed the size. Is there a command I need to run first to remove old information first, before running the shrink?
When I go into the Enterprise manager I have 2 SQL groups. Once is local and the other is listed by the server name. The database problem is happening on the 2nd gorup. When I try to manually increase the size of the data file it says due to licensing restrictions I am limited to 2048 MB. The SQL instances in the other group allow me to change that number above 2048 MB.

The 2GB database size limit only applies to MSDE (the free, "desktop" version of SQL 2000). Other SQL 2000 version don't have that limitation.
There is no "magic" way to purge or archive old, historical data. You have to know your database and its structure, your customer requirements, and your data retention needs.

You can try this:
ALTER DATABASE foo ADD FILE (
NAME = 'file2',
FILENAME = 'C:\PATH\TO\FILE.ndf',
SIZE = 100MB,
MAXSIZE = UNLIMITED,
FILEGROWTH = 10MB;
Make sure you back up first.
Also, are you running SQL Server Express? There is a definite 2GB limit there...

MDF files are where the data is stored, so it's possible it holds that much data.
I've got a MDF file of 13GB so I don't believe that limit is correct.
Regarding shrinking this, by removing data, you might delete some data, and then shrink it, or you could extend that filegroup, by adding another data file to it.
Alternatively create a database maintainence plan to reduce the amount of free space per page, and also possibly remove unused space.
I would suggest you extend it, and then review your maintenance plans to ensure they are correct.

Related

PRIMARY filegroup is full

Since there is no space left on my SQL server, I keep getting the following error and I have to delete data to get the system working again.
The hosting company says we do not have unlimited package options. They suggest that we switch to the server. Apart from that, I saw the 'shrink' on the internet, but will this damage the database or will it be the definitive solution for me?
Could not allocate space for object in database 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.
As has been mentioned in the comments, Shrink Database won't help you because SQL Server will use all free space in the file before it attempts to grow it.
So your options are as follows:
Archive or delete old data
If you have audit tables, large blobs that no longer need to be accessed, or other data that doesn't need to be accessed within your application any more, you can SELECT it out of the database, store it in a file somewhere as an archive (or retrieve it from an older backup when you need it).
Apply table compression
If you are running Enterprise SQL, or a version of Standard/Express/Web after 2016 SP1, you can apply Compression to larger tables. This converts CHAR columns to be physically stored as VARCHAR columns, among other things, and I have seen it gain 1/3 space back on some SQL databases. However, you will run into the problem of needing space initially to perform the compression in, so you may need to apply this in concert with #1. A restart of the database service may also give you some space back from tempdb in which to operate if your tempdb has filled.
Upgrade storage space
If your host can't meet your storage space needs and #1 and #2 are not possible, it may be time to look at changing hosts. This may be a good idea anyway as your database will no doubt eventually grow back to bigger than its current size.
Keep in mind that if you have microsoft sql express server the license limits you to about 10 GB per database so you cannot increase the primary group more than that. For Sql Express Server before 2008 the size limit is even less.

Could not allocate a new page for database because of insufficient disk space in filegroup

while running a program in SAS conected to SQL-server 2008 I am getting this ERROR in the log:
Execute error: ICommand::Execute failed. : The statement has been terminated.:
Could not allocate a new page for database 'databse' because of insufficient disk space in
filegroup 'CURRENT01'. Create the necessary space by dropping objects in the filegroup,
adding additional files to the filegroup, or setting autogrowth on for existing files in
the filegroup.
I am looking to similar problems and I can not really see the solution.
I am quite sure we have enough space in the database.
is it maybe anything related with the work? I am quite new with SQL server.
Thank you, in advance, for your help.
Check the settings of data file(s) in that file group. Most likely their upper size limit is capped in which case it does not matter if you have free space.
You can find these settings with Management Studio: right click the database -> Properties -> Files -> Column Autogrowth/Max Size.
You should also check that the database files are on the disk drive where you expect them to be.
For Errors like this, your database is taking disk space and not the space available to DB, this happens when you are doing bulk Insert operation (Mostly).
You can see it by clicking the database -> Properties -> Files -> Database - space available and size.
Try Dropping some tables and then release the space.

Empty database over 10GB in size

While I was trying to populate a table from a 11GB text file (.tsv) I got the error:
Could not allocate space for object 'X' in database 'Y' 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.
I thought the problem was the database exceeded 10GB, which is the limit for SQL Express. Yet, when I checked, I noticed the database is actually empty. The query
SELECT TOP 10 *
FROM Table
Takes several minutes to execute and it gives me back nothing. When I checked under properties > files I found out filegroup PRIMARY is actually 10240MB.
What is this about, and how can solve the problem?
Populating 11GB text file into SQL server express will give an error since it will exceed the edition limit. You either split the text file into 2 files or upgrade to standard edition. Or try Oracle XE? It store up to 11GB :) might be just enough for you.

SQL Server filegroup full during a large INSERT INTO statement

Consider a SQL script designed to copy rows from one table to another in a SQL 2000 database. The transfer involves 750,000 rows in a simple:
INSERT INTO TableB([ColA],[ColB]....[ColG])
SELECT [ColA],[ColB]....[ColG]
FROM TableA
This is a long running query, perhaps in part because ColB is of type ntext.
There are a handful of CONVERT() operations in the SELECT statement.
The difficulty is that after ~15 mins of operation, this exception is raised by SQL Server.
Could not allocate space for object '[TABLE]'.'[PRIMARY_KEY]' in database '[DB]' 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.
More Info
Autogrowth is already on.
there is more than enough free space on disk (~20gb)
the single .mdf is ~6gb
no triggers on the source or target tables
Question
What options need to be set, either via Management Studio, or via T-SQL to allow the database to grow as required? What other remedies would you suggest?
Resolution
The db could not grow as needed because I was hosting this database on an instance of SQL Server 2008 Express. Upgrading to a non-neutered version of SQL Server will solve this problem.
Best advice: Pre-size your database larger, instead of forcing it to grow on-demand (which can be a slow operation).
One reason this error could occur is if your autogrow interval is set too large. Besides the obvious (trying to grow by 25GB with only 20GB on disk), a large growth interval can take a very long time to allocate, which can cause your query to time out.
EDIT: Based on your new screenshot, doesn't look like the interval is the problem. But, my original advice still stands. Try to manually grow the database yourself, and see if it lets you:
ALTER DATABASE foobar
MODIFY FILE (name = foobar_data, size = 5000)
If you can share a screenshot/information on your PRIMARY filegroup makeup and autogrow settings (i.e. all files included in the PRIMARY and the autogrow settings for each) that would be helpful as well. First thought without seeing anything additional would be that you potentially have a maxFileSize specified for one/more of the files that makeup your PRIMARY group, but that's just a hunch without actually seeing the information.
Is there any triggers on the table in question? I've seen similar results before when there was triggers and it was actually the expansion of the log file (ldf) which reached the limit just logging all the queries that were being ran by triggers and not the mdf itself. If there is any triggers I'd consider disabling them while you do this update and seeing if that helps (I assume this is a 1-off data migration rather than a recurring event?)

Discrepency in the size of mdf files in SQL server

I am having 2 .bak files for the same database in MSSQL Server. One is the test snapshot and the other is the production snapshot. The test one is about 500 MB and the production one is about 10 GB. This is because the Test one has many tables truncated. When I restore them in sql server a .mdf file is created at \Microsoft SQL Server\MSSQL.1\MSSQL\Data folder. But I see that the sze of the .mdf file is about 10 GB even when I restore only the test snapshot. Since the test snapshot has many tables truncated and data is less, I would assume that the the size of the .mdf file should be less than that for production snapshot. But that is not the case. Does sql server reserve space in the mdf file and hence it is the same size for both the versions?
Yes it does reserve space. You can see this in the create database page and later in the properties pages.
MDF = space reserved
bak = 8k pages with data
When the database is restored, it reads the size from sys.database_files. The pages are put back into the same relative place.
Unless you are really short of disk space, I'd leave it... but you can shrink the files if it makes you feel better
You are using (ballpark figures) 64,000 pages but have reserved 12,800,000
i think you need to run the following on your DB.
DBCC SHRINKDATABASE (UserDB, 10);

Resources