Solved

Shrinking SQL Log File

Posted on 2012-03-22
2
480 Views
Last Modified: 2012-03-22
I need to shrink a SQL log file, but the log file is named exactly the same as the DB (with the exception of the ".ldf" extension and it's on a different drive.   I'm scared that if I call

DBCC SHRINKFILE(N'CRMDB', 1)

it will try to shrink the database, not the log.   How do I ensure the logfile will be what is shrunk?  My code is below.

USE CRMDB
GO
ALTER DATABASE CRMDB
SET RECOVERY SIMPLE
DBCC SHRINKFILE(N'CRMDB', 1)
ALTER DATABASE CRMDB
SET RECOVERY FULL
GO
0
Comment
Question by:saturation
  • 2
2 Comments
 
LVL 16

Assisted Solution

by:The_Kirschi
The_Kirschi earned 500 total points
ID: 37753660
Why don't you specify the filename as CRMDB.ldf?

You could also use the Management Studio like this:
      

Right click on the database name.

Select Tasks -> Shrink -> Database
0
 
LVL 16

Accepted Solution

by:
The_Kirschi earned 500 total points
ID: 37753673
Try to get the logical file name of the transaction log like specified here and use that one:

http://stackoverflow.com/questions/1435935/how-to-get-the-logical-name-of-the-transaction-log-in-sql-server-2005
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Hi all, It is important and often overlooked to understand “Database properties”. Often we see questions about "log files" or "where is the database" and one of the easiest ways to get general information about your database is to use “Database p…
SQL Server engine let you use a Windows account or a SQL Server account to connect to a SQL Server instance. This can be configured immediatly during the SQL Server installation or after in the Server Authentication section in the Server properties …
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now