I need to empty an LDF file before sending to a colleague. How do I force SQL Server to truncate the log?
相关问题
- sql execution latency when assign to a variable
- What is the best way to cache a table from a (SQL)
- php PDO::FETCH_ASSOC doesnt detect select after ba
- Bulk update SQL Server C#
- SQL to Parse a Key-Value String
相关文章
- how do I log requests and responses for debugging
- Entity Framework 4.3.1 failing to create (/open) a
- Code for inserting data into SQL Server database u
- Delete Every Alternate Row in SQL
- Linux based PHP install connecting to MsSQL Server
- SQL Azure Reset autoincrement
- How do we alias a Sql Server instance name used in
- Is recursion good in SQL Server?
For SQL Server 2008, the command is:
This reduced my 14GB log file down to 1MB.
For SQL 2008 you can backup log to
nul
device:And then use
DBCC SHRINKFILE
to truncate the log file.if I remember well... in query analyzer or equivalent:
In management studio:
Properties
, thenOptions
.Tasks
->Shrink
->Files
Alternatively, the SQL to do it:
Ref: http://msdn.microsoft.com/en-us/library/ms189493.aspx
backup log logname with truncate_only followed by a dbcc shrinkfile command
Another option altogether is to detach the database via Management Studio. Then simply delete the log file, or rename it and delete later.
Back in Management Studio attach the database again. In the attach window remove the log file from list of files.
The DB attaches and creates a new empty log file. After you check everything is all right, you can delete the renamed log file.
You probably ought not use this for production databases.