Reducing a Log file on a Published Database

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
------------------------------------------------
-- Switch in Single User mode
------------------------------------------------
ALTER DATABASE DatabaseName SET SINGLE_USER WITH ROLLBACK IMMEDIATE
 
------------------------------------------------
-- Delete replication transactions
-- currently running on the published database
------------------------------------------------
USE DatabaseName
go
sp_repldone @xactid = NULL, @xact_segno = NULL, @numtrans = 0,
@time = 0,
@reset = 1
go
 
------------------------------------------------
-- Log Shrink
------------------------------------------------
DBCC SHRINKFILE(DatabaseLogName, 100)
-- If there is no effect, you can execute the following commands:
-- BACKUP LOG DatabaseName WITH TRUNCATE_ONLY
-- DBCC OPENTRAN(DatabaseName)
 
------------------------------------------------
-- Switch on Multi User mode
------------------------------------------------
ALTER DATABASE DatabaseName SET MULTI_USER WITH ROLLBACK IMMEDIATE
------------------------------------------------
-- RESTART
------------------------------------------------
USE DatabaseName
exec sp_replrestart