The transaction log does not automatically shrink after the SHRINKFILE is done. Actual file shrinking is done periodically by the server and depends on :
1. The location of the last log entry on the transaction log. If the last log entry is near the end of the transaction log file, then the file cannot be
shrinked beyond it. Note that log shrinking is done from the end of the file until it encounters the last log entry. More information in BOL DBCC
SHRINKFILE.
2. The target log file size as defined by a SHRINKFILE parameter.
3. The server has heuristics keeping track of the amount of log space being consumed by the server (ie. the amount of log space used before a checkpoint) and uses this info to determine by how much (increments) to shrink the transaction log file.
Please go through the following steps :
1. USE <dbname>
GO
2. DBCC SHRINKFILE (<File_name>, 500, NOTRUNCATE)
As per BOL, The only effect of the DBCC SHRINKFILE is to relocate used pages from above the target_size line to the front of the file. Note the NOTRUNCATE does not free any space for the operating system, hence, Step3.
3. DBCC SHRINKFILE (<File_name>, 500, TRUNCATEONLY)
Causes any unused space in the files to be released to the operating system and shrinks the file to the last allocated extent, reducing the file size without moving any data.
No attempt is made to relocate rows to unallocated pages. target_size is ignored when TRUNCATEONLY is used.
Since DBCC Shrinkfile, does not automatically shrink the size of the file, we need to do some transactions to move the active portion of the log and do several dumps (step 4).
4. <<Script>>
use Yourdatabase
go
create table t1 (char1 char(4000))
go
declare @i int
select @i = 0 while (1 = 1)
begin
while (@i < 100)
begin
insert into t1 values ('a')
select @i = @i +1
end
truncate table t1
backup log TemplateV3 with truncate_only
end
go
Let Step4 run several iterations, until you feel that the enough log entries have been processed (the active Virtual file is 105MB in size)
5. Check the size of your transaction log.