?
Solved

DBCC Shrinkfile with emptyfile help requested

Posted on 2007-07-26
9
Medium Priority
?
1,817 Views
Last Modified: 2012-08-14
In Microsoft SQL Server we deleted a lot of data in a column in our table by updating with NULLS, which has not been reclaimed.

I am currently running dbcc shrinkfile (datafile, emptyfile) to empty the file into another on the same drive.

It's working and it's removing data from the primary data file and moving it to the second data file.

However, the system will run out of disk space before It's completed.

How do I shrink the bulk-logged database file while the dbcc shrinkfile emptyfile is running?
0
Comment
Question by:Promethyl
  • 5
  • 3
9 Comments
 
LVL 13

Expert Comment

by:ispaleny
ID: 19597007
Terminate the shrink operation. Any completed work is retained.
From http://msdn2.microsoft.com/en-us/library/ms190488.aspx
0
 
LVL 7

Author Comment

by:Promethyl
ID: 19597366
Yes, the work is retained, but the file is not shrunk.
0
 
LVL 13

Expert Comment

by:ispaleny
ID: 19598571
Backup the log.
Or shrink it without backup:
BACKUP LOG YourDatabase WITH TRUNCATE_ONLY
0
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
LVL 7

Author Comment

by:Promethyl
ID: 19599960
It is not the log file which has grown. It's the database file.

Doing this sort of shrinkfile, the database datafile now has lots of free space, but the log file is 1M.
0
 
LVL 13

Expert Comment

by:ispaleny
ID: 19602981
I.Try to free some space first:
1. Shrink datafile to the last occupied extent (db sector)
    DBCC shrinkfile (datafile, TRUNCATEONLY)
2. Shrink all database files to the last occupied extent (db sector)
    DBCC shrinkdatabase(N'YourDatabase',  TRUNCATEONLY )

II. Else defragment structures.
   Compressed tables with packed indexes are better read, but worse written.
   You can change table fill ratio in db maintenance job later.
1.Shrink datafile with defragmentation
    a) partial - specify number for target_MB_size parameter
    DBCC shrinkfile (datafile,target_MB_size)
    b) full
    DBCC shrinkfile (datafile)
2. Shrink all database files with defragmentation
    a) partial - specify number for target_percent_integer parameter
    DBCC shrinkdatabase(N'YourDatabase',target_percent_integer)
    b) full
    DBCC shrinkdatabase(N'YourDatabase')
0
 
LVL 7

Author Comment

by:Promethyl
ID: 19604403
I'm running th shrinkfile on the datafile, and it's not getting smaller. Any ideas?
0
 
LVL 7

Accepted Solution

by:
Promethyl earned 0 total points
ID: 19992687
Actual answer was to backup the datafile first and then shrink. You cannot shrink the pages until they've been backed up.
 
0
 
LVL 21

Expert Comment

by:Kevin3NF
ID: 20388857
Did you notice any negative effects of the TRUNCATEONLY option on the datafile?  I've used it many times on a logfile....

Thanks
0
 
LVL 7

Author Comment

by:Promethyl
ID: 21721774
Well, I suppose if you're releasing size, it fragments the drive horribly over time.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
Windocks is an independent port of Docker's open source to Windows.   This article introduces the use of SQL Server in containers, with integrated support of SQL Server database cloning.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Suggested Courses

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question