?
Solved

Shrinking SQL Log File

Posted on 2012-03-22
2
Medium Priority
?
496 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Naughty Me. While I was changing the database name from DB1 to DB_PROD1 (yep it's not real database name ^v^), I changed the database name and notified my application fellows that I did it. They turn on the application, and everything is working. A …
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 …
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

777 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