全部删除:
1dump transaction master with no_log;
2dump transaction master with truncate_only
2dump transaction master with truncate_only
单个删除:
1DUMP TRANSACTION @DataBaseName WITH NO_LOG
2DBCC SHRINKFILE( @LogoFileName,@NewSize) --收缩 日志
3declare @dbname varchar(20)
4set @dbname='THSYBSecondTest'
5
6--1.清空日志
7exec('DUMP TRANSACTION ['+@dbname+'] WITH NO_LOG')
8
9--2.截断事务日志:
10exec('BACKUP LOG ['+@dbname+'] WITH NO_LOG')
11
12--3.收缩数据库文件(如果不压缩,数据库的文件不会减小
13exec('DBCC SHRINKDATABASE(['+@dbname+'])')
14
15--4.设置自动收缩
16exec('EXEC sp_dboption '''+@dbname+''',''autoshrink'',''TRUE''')
2DBCC SHRINKFILE( @LogoFileName,@NewSize) --收缩 日志
3declare @dbname varchar(20)
4set @dbname='THSYBSecondTest'
5
6--1.清空日志
7exec('DUMP TRANSACTION ['+@dbname+'] WITH NO_LOG')
8
9--2.截断事务日志:
10exec('BACKUP LOG ['+@dbname+'] WITH NO_LOG')
11
12--3.收缩数据库文件(如果不压缩,数据库的文件不会减小
13exec('DBCC SHRINKDATABASE(['+@dbname+'])')
14
15--4.设置自动收缩
16exec('EXEC sp_dboption '''+@dbname+''',''autoshrink'',''TRUE''')