473,897 Members | 2,577 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem with database filegroup restructuring in SQL Server?

Hi,

I have the following SQL procedure I am running to clean up a filegroup
and move all data to a single .MDF file:

use <db_name>
print 'Move <db_name> db contents to MDF file'
DBCC SHRINKFILE ('<db_name>_1_D ata', EMPTYFILE)
DBCC SHRINKFILE ('<db_name>_Log ', EMPTYFILE)
DBCC SHRINKFILE ('<db_name>_2_D ata', EMPTYFILE)
DBCC SHRINKFILE ('<db_name>_log 2', EMPTYFILE)
go

Trouble is that I get the following error:

Server: Msg 1105, Level 17, State 2, Line 3
Could not allocate space for object '<company_name> . Inv. Line' in
database '<db_name>' because the 'Data Filegroup 1' filegroup is full.

There are five files:
- a .MDF file (which is already set as the primary filegroup, 43MB in
size);
- <db_name>_1_dat a.ndf (this file is 11GB in size);
- <db_name>_2_dat a.ndf (this file is 4GB in size, empty & cannot be
shrunk);
- 2 .LDF files

I have been able to remove the "<db_name>_2_da ta.ndf" file
successfully, but moving the objects from filegroup 1 to the primary
filegroup has yielded the same error message every time. Any ideas on
what I can do to resolve this?

Mar 6 '06 #1
1 2725
(jk********@yah oo.com) writes:
I have the following SQL procedure I am running to clean up a filegroup
and move all data to a single .MDF file:

use <db_name>
print 'Move <db_name> db contents to MDF file'
DBCC SHRINKFILE ('<db_name>_1_D ata', EMPTYFILE)
DBCC SHRINKFILE ('<db_name>_Log ', EMPTYFILE)
DBCC SHRINKFILE ('<db_name>_2_D ata', EMPTYFILE)
DBCC SHRINKFILE ('<db_name>_log 2', EMPTYFILE)
go

Trouble is that I get the following error:

Server: Msg 1105, Level 17, State 2, Line 3
Could not allocate space for object '<company_name> . Inv. Line' in
database '<db_name>' because the 'Data Filegroup 1' filegroup is full.


As I understand you can only use EMPTYFILE to move data within a
filegroup, you cannot use it to move the data another file group.

To do this, you need to use CREATE CLUSTERED INDEX WITH DROP_EXISTING to
move the tables. Of course, you need to move non-clustered indes as well.
Please check Books Online, for the exact syntax.

--
Erland Sommarskog, SQL Server MVP, es****@sommarsk og.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx
Mar 7 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
4499
by: el emperador | last post by:
I have a big table (heap)... well, not so big, I have a small server and I want to spread access to it across several new disks dedicated only to that table. I known its possible to do that creating a clustered index with "ON filegroup" option but I want to maintain it as a heap, is there any way to do this without dropping indexes/references - bulk unload - create table - bulk load - create indexes?.
4
2467
by: mike | last post by:
Hi, I am trying to determine what the overhead is per database in SQL Server 2000 Standard. I have the option to put several customers in one database, or give each customer their own database. I would like to put each customer in their own database to simplify maintenance and strengthen security. I have found the following document which shows the memory used by various objects in SQL Server:
8
2050
by: David | last post by:
Hi, Could someone please xplain how to add a field to an existing SQL table in VB.Net I have added the field in the Server Explorer and it shows up when I reload the program but I cannot access the field from within my program. Is there something I need to refresh or do I need to recreate he Dataapdtors
4
1778
by: Dr Warehouse | last post by:
Hi, I am expanding our data warehouse solution with new filegroups on several subsystems. I want to know which idea is better! - create clustered indexes on tables to 'move' them to new filegroups - create these tables on the new filegroups.
0
1255
by: Takpol | last post by:
Greetings Group Members, I am going to implement a strategy for archiving and restoring old filegroups. Part of my data has been stored in date partitioned files and filegroups. So the archive is going to backup older than six months filegroups into the tape and removes them from the production database. The restore strategy is going to work as this: user would be able to ask for restoring old filegroups. Every time there is a restore...
3
6408
by: Nasir | last post by:
What is the best way to resolve these collation errors: My server is installed as - Latin1_General_CS_AS, but one of the important 50GB databases migrated from another server has - SQL_Latin1_General_CP1_CS_AS, and we are getting errors: Msg 468, Level 16, State 9, Line 1 Cannot resolve the collation conflict between "Latin1_General_CS_AS" and "SQL_Latin1_General_CP1_CS_AS" in the equal to operation
1
2025
by: Chessie | last post by:
I'm currently working on Table Partitioning. I have done everything succesfull for partitioning, what I'm struggling with is to use " SELECT MAX(NAME) from sys.filegroups WHERE NAME NOT LIKE 'PRIMARY' " to get the last used FileGroup. Now this works just fine, but when I run the following script: --Decalre variables DECLARE @LastFilegroupName VARCHAR(50) DECLARE @FilegroupName VARCHAR(50) --Retuns the next FileGroup to be used SET...
0
1131
by: tz71 | last post by:
If a new filegroup is created on a new disk drive, is there a way to migrate a specific clustered index to the new filegroup? SQL Server 2005 SP2 kb
1
936
by: Utahduck | last post by:
I've been having some issues so forgive me if this double-posts. Because I have some large but static Filegroups within a database I prefer to backup my filegroups instead of everything at once. This is SQL Server 2000. The other day I backed up a file with this command: BACKUP DATABASE Thomasville FILEGROUP = 'PRIMARY'
0
9990
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
11250
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10476
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9655
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
8031
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5872
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6073
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4292
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3299
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.