?
Solved

How to move LDF file to another drive for already created database?

Posted on 2011-02-17
3
Medium Priority
?
612 Views
Last Modified: 2012-05-11
I have a 23GB database MDF and 1GB database LDF located in E:\SQLServer.

I understand that if I shift my LDF file to another hard disk, eg. D:, the performance might be slightly faster.

I tried to detach the database and delete the LDF file. When I reattach the MDF, SQL2000 will re-create the LDF file back in E:\SQLServer, but I wish to move the LDF file to D:\, which is another hard disk. How do I do this?

Thank you.
0
Comment
Question by:cq27
[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
3 Comments
 
LVL 12

Expert Comment

by:mcv22
ID: 34923765

ALTER DATABASE DatabaseName MODIFY FILE (NAME = Database_Log, FILENAME = 'D:\SQLServer\Database_log.ldf')

Open in new window

0
 
LVL 15

Accepted Solution

by:
Aaron Shilo earned 500 total points
ID: 34923769
hi

why did you delete the LDF?

use master
GO
   sp_detach_db 'YOURDATABASE'
   go
   sp_attach_db 'YOURDB','E:\Sqldata\DATAFILE.mdf','D:\Sqldata\LOGFILE.ldf'
   go

0
 

Author Closing Comment

by:cq27
ID: 34923816
Thanks for your solution. It is the easiest to understand. I tried to follow others' instructions but no one seem to be as clear as yours.

I have tried it on a test database and it works. Thank you.
0

Featured Post

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

Question has a verified solution.

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

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.
Suggested Courses

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