收缩数据库可以把没有使用的空间释放出来。 DUMP TRANSACTION @DataBaseName WITH NO_LOG DBCC SHRINKFILE( @LogoFileName,@NewSize)
可以缩小日志文件。

解决方案 »

  1.   

    可以用:DBCC SHRINKFILE(filename,size)
      

  2.   

    sp_attach_single_file_db
    用它可以减小ldf文件的大小的
      

  3.   

    Script to Shrink Log FilesThis script will take the name of a specific log file, its database, and a desired file size, and will then proceed to compress the given log file. All that needs to be entered is the "tx-logname", "DESIRED_FINAL_SIZE_IN_MB", and "basename". Author: Conrado Pacheco 
    DBCC SHRINKFILE (<tx-logname>  , <DESIRED_FINAL_SIZE_IN_MB>,TRUNCATEONLY )
    go
    BACKUP LOG  <basename> WITH TRUNCATE_ONLY
    godrop table mytable
    goCREATE 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 /* Some criteria to restrict to one row. */
    SELECT @Index = @Index + 1
    END
    SET NOCOUNT OFF
    goDBCC SHRINKFILE ( <tx-logname> ,<DESIRED_FINAL_SIZE_IN_MB>, truncateonly )
    go
    BACKUP LOG < basename > WITH TRUNCATE_ONLY
    go