Solved

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

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

Why You Need a DevOps Toolchain

IT needs to deliver services with more agility and velocity. IT must roll out application features and innovations faster to keep up with customer demands, which is where a DevOps toolchain steps in. View the infographic to see why you need a DevOps toolchain.

Question has a verified solution.

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

Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
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.

739 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