Solved

Shrinking SQL Log File

Posted on 2012-03-22
2
482 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

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

786 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