Click here to Skip to main content
15,885,278 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi i need help on sql

i have tabel and i inser 100000+ records to test the speed of aplication
and the (.ldf) file was 52.3 MB
and i delete all records and the (.ldf) file is still 52.3 MB can some one give me suggestion how to free the file??
Posted
Updated 20-Mar-13 2:59am
v2
Comments
Aarti Meswania 20-Mar-13 9:05am    
Apply indexing and fire reindexing query once or twice a day based on new record insertion-update or delete

Hello,

Use SHRINKFILE to shrink the data file size. According to the documentation on MSDN[^] SHRINKFILE
Shrinks the size of the specified data or log file for the current database, or empties a file by moving the data from the specified file to other files in the same filegroup, allowing the file to be removed from the database. You can shrink a file to a size that is less than the size specified when it was created. This resets the minimum file size to the new value
The syntax is
DBCC SHRINKFILE 
(
    { file_name | file_id } 
    { [ , EMPTYFILE ] 
    | [ [ , target_size ] [ , { NOTRUNCATE | TRUNCATEONLY } ] ]
    }
)
[ WITH NO_INFOMSGS ]
 
Share this answer
 
Comments
nika2008 20-Mar-13 9:23am    
thnx alot +5
Monjurul Habib 20-Mar-13 15:19pm    
5++
Basically, you can't - deleting records does not reduce the size of the file, the space is just released for future records.
You need to use the management studio to Shrink it: MSDN[^]
 
Share this answer
 
Comments
nika2008 20-Mar-13 9:23am    
thnx alot +5
Monjurul Habib 20-Mar-13 15:19pm    
5++

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900