日期:2014-05-17  浏览次数:20629 次

SQL2008压缩日志文件
这么操作为何不行呢?
USE DBNAME
GO
-- Truncate the log by changing the database recovery model to SIMPLE.
ALTER DATABASE DBNAME
SET RECOVERY SIMPLE;
GO
-- Shrink the truncated log file to 1 MB.
DBCC SHRINKFILE (DBNAME_Log, 1,TRUNCATEONLY);
GO
-- Reset the database recovery model.
ALTER DATABASE DBNAME
SET RECOVERY FULL;
GO

会报错:Msg 8985, Level 16, State 1, Line 2
Could not locate file 'DBNAME_Log' for database 'DBNAME' in sys.database_files. The file either does not exist, or was dropped.

------解决方案--------------------
貌似是log的名称写错了。查一下sys.database_files
我执行的语句,没有问题。

SQL code
CREATE DATABASE DBT 
go

USE DBT
GO
-- Truncate the log by changing the database recovery model to SIMPLE.
ALTER DATABASE DBT
SET RECOVERY SIMPLE;
GO
-- Shrink the truncated log file to 1 MB.
DBCC SHRINKFILE (DBT_Log, 1,TRUNCATEONLY);
GO
-- Reset the database recovery model.
ALTER DATABASE DBT
SET RECOVERY FULL;
GO

------解决方案--------------------
The file either does not exist, or was dropped. 

文件不存在或者被删除了。
------解决方案--------------------
文件不存在或被删除。
------解决方案--------------------
探讨

引用:

貌似是log的名称写错了。查一下sys.database_files
我执行的语句,没有问题。

SQL code
CREATE DATABASE DBT
go

USE DBT
GO
-- Truncate the log by changing the database recovery model to SIMPLE.
……