I'm trying to shrink the log of a database AND set the recovery to simple , but always there is an error, whatever i try.
USE 4_o5;
GO
ALTER DATABASE 4_o5
SET RECOVERY SIMPLE;
GO
DBCC SHRINKFILE (4_o5_log, 10);
GO
the output of sp_helpfile says that log file is located under (hosted solution):
I:\dataroot\4_o5_log.LDF
please help me perform this operation as the log file got large when importing a lot of data and now this info is no longer needed, have multiple (lots of) backups since then.
the exact error message when performing the query above is:
incorrect syntax near '4'.
RECOVERY is not a recognized SET option.
incorrect syntax near _5_log'.
I am using Visual Studio 2010 (also have SQL Server Express installed locally, SQL Server 2008 proper installed at provider (shared))
thnx a lot
Just do
USE [4_o5] --need brackets with this DB name, as marc_s commented
GO
DBCC SHRINKFILE (2, 10)
DBCC also takes the internal file id number and I see you're having problems separating logical and physical file names... which leads me to assume you don't have multiple log files or NDFs etc and the log file will always be 2
However, why do you want to shrink anyway?
To change recovery model: ALTER DATABASE [4_o5] SET RECOVERY SIMPLE
Try this:
USE [4_o5];
GO
ALTER DATABASE [4_o5] SET RECOVERY SIMPLE;
GO
DBCC SHRINKFILE ([4_o5_log], 10);
GO
Your database name starting with a numeric value is a bit unusual - try putting it in square brackets.
UPDATE: for the DBCC SHRINKFILE
, you need the logical name of the log file - that's the name
property from the sp_helpfile
call. And you also need to put it in square brackets:
USE [4_o5]
GO
DBCC SHRINKFILE ([4_o5_log], 10)
GO
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.