Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Shrinking SQL Log File

Posted on 2012-03-22
2
Medium Priority
?
499 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 16

Assisted Solution

by:The_Kirschi
The_Kirschi earned 2000 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 2000 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

618 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