April 29, 2011 at 6:46 pm
I'm having problems with Shrinkfile. I wish to use the option to migrate the data to other files, and then delete the file.
It takes several hours to operate a single shrink operation. And then it usually gives an error message. It only works sometimes.
Any ideas what could be wrong?
I am, by the way, using SQL Server management Studio. How do I get the file ID number to run it as a SQL statement?
April 29, 2011 at 8:12 pm
qwerty 87425 (4/29/2011)
And then it usually gives an error message....
...
Any ideas what could be wrong?
Not without seeing the error message you're getting. 😉
--Jeff Moden
Change is inevitable... Change for the better is not.
April 29, 2011 at 11:32 pm
An exception occurred while executing a Transact-SQL statement or batch.
(Microsoft.SqlServer.ConnectionInfo)
Cannot move all contents of file "Data_File_12" to other places to complete the
emptyfile operation. DBCC execution completed. If DBCC printed error
messages, contact your system administrator. (Microsoft SQL Server, Error:
2555)
April 30, 2011 at 11:31 am
What query are you running to empty the file ?
Thank You,
Best Regards,
SQLBuddy
April 30, 2011 at 5:04 pm
I'm not running a query, I'm using Tasks > Shrink > Files in the management studio.
May 1, 2011 at 1:06 am
First thing is you cant delete primary file and Second thing is organize the database with
USE [database name]
GO
DBCC SHRINKDATABASE(N'Database Name', 1 )
GO
It will works for all data files and then apply
USE [Database Name]
GO
DBCC SHRINKFILE (N'Database Name' , EMPTYFILE)
GO
how many drives you have not partitions
Regards,
Syed Jahanzaib Bin Hassan
MCTS | MCITP | OCA | OCP | OCE | SCJP | IBMCDBA
My Blog
Regards,
Syed Jahanzaib Bin Hassan
BSCS | MCTS | MCITP | OCA | OCP | OCE | SCJP | IBMCDBA
My Blog
www.aureus-salah.com
May 1, 2011 at 7:36 am
This is how you need to remove a file
http://msdn.microsoft.com/en-us/library/ms189493.aspx
D. Emptying a file
The following example demonstrates the procedure for emptying a file so that it can be removed from the database. For the purposes of this example, a data file is first created and it is assumed that the file contains data.
USE AdventureWorks2008R2;
GO
-- Create a data file and assume it contains data.
ALTER DATABASE AdventureWorks2008R2
ADD FILE (
NAME = Test1data,
FILENAME = 'C:\t1data.ndf',
SIZE = 5MB
);
GO
-- Empty the data file.
DBCC SHRINKFILE (Test1data, EMPTYFILE);
GO
-- Remove the data file from the database.
ALTER DATABASE AdventureWorks2008R2
REMOVE FILE Test1data;
GO
Thank You,
Best Regards,
SQLBuddy
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply