mardi 30 juin 2009

Réduire la taille du fichier log (.LDF) de MSDE-SQL

--1
DBCC SHRINKFILE ('{filename}.ldf', TRUNCATEONLY )
BACKUP LOG {database} WITH TRUNCATE_ONLY

--2
CREATE TABLE MyTable (MyField VARCHAR(10), PK INT )
INSERT Mytable (PK) VALUES (1)
GO

SET NOCOUNT ON
DECLARE @Index INT
SELECT @Index = 0
WHILE (@Index < 20000)
BEGIN
UPDATE MyTable SET MyField = MyField WHERE PK = 1
SELECT @Index = @Index + 1
END
SET NOCOUNT OFF

--3(REPEAT/REPETER)
DBCC SHRINKFILE ('{filename}.ldf', TRUNCATEONLY )
BACKUP LOG {database} WITH TRUNCATE_ONLY

--4
DROP TABLE MyTable



* source
http://www.broad-lea.com/sql_server/sql_reduce_log_size.html

lundi 15 juin 2009