Unix Technical Forum

Problem with database filegroup restructuring in SQL Server?

This is a discussion on Problem with database filegroup restructuring in SQL Server? within the SQL Server forums, part of the Microsoft SQL Server category; --> Hi, I have the following SQL procedure I am running to clean up a filegroup and move all data ...


Go Back   Unix Technical Forum > Database Server Software > Microsoft SQL Server > SQL Server

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-29-2008, 06:36 PM
jkv10_2005@yahoo.com
 
Posts: n/a
Default 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_Data', EMPTYFILE)
DBCC SHRINKFILE ('<db_name>_Log', EMPTYFILE)
DBCC SHRINKFILE ('<db_name>_2_Data', EMPTYFILE)
DBCC SHRINKFILE ('<db_name>_log2', 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_data.ndf (this file is 11GB in size);
- <db_name>_2_data.ndf (this file is 4GB in size, empty & cannot be
shrunk);
- 2 .LDF files

I have been able to remove the "<db_name>_2_data.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?

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-29-2008, 06:37 PM
Erland Sommarskog
 
Posts: n/a
Default Re: Problem with database filegroup restructuring in SQL Server?

(jkv10_2005@yahoo.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_Data', EMPTYFILE)
> DBCC SHRINKFILE ('<db_name>_Log', EMPTYFILE)
> DBCC SHRINKFILE ('<db_name>_2_Data', EMPTYFILE)
> DBCC SHRINKFILE ('<db_name>_log2', 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, esquel@sommarskog.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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 01:19 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com