Solved

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

Posted on 2011-02-17
3
611 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 125 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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

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 part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

707 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