Knowledgebase / FAQ - ip-connect GmbH
Knowledgeroot - Version: 0.9.9.5
Menü verstecken Menü ausklappen Menü neuladen Menü einklappen
Menü schliessen
  1.    (Zuletzt geändert von rsch an 01.02.2011 00:21:04)

“WITH TRUNCATE_ONLY” command is no longer in SQL 2008. Assuming you run in full recovery mode, the new script to do this is:

USE [{DatabaseName}]
GO
ALTER DATABASE [{DatabaseName}] SET RECOVERY SIMPLE
GO
DBCC SHRINKFILE({TransactionLogLogicalName})
GO
ALTER DATABASE [{DatabaseName}] SET RECOVERY FULL
GO

Simply setting the database mode into simple recovery mode performs the actual truncation but the file is not shrunk by that. DBCC SHRINKFILE will take care of that second step. And don’t forget to put it back into full recovery mode at the end!!

verschieben [Oben]

  2.SQL-Server Shrink T-LOG    (Zuletzt geändert von rsch an 16.10.2012 22:29:42)
USE [db-name]
GO
DBCC SHRINKFILE('db-name_Log', 1)
BACKUP LOG [db-name] WITH TRUNCATE_ONLY
DBCC SHRINKFILE('db-name_Log', 1)

Der Log-Name ergibt sich aus aus der Systemtabelle 'sysfiles'.
(select * from sys.database_files)

verschieben [Oben]