Answered by:
Move log files for SQL 2005 databases to another drive

Question
-
Hello,
I need to move all log files for my SQL 2005 databases to another drive. I don't wish to shrink the files, I need to move the logs to another drive spindle. I did find an article (Article ID: 224071) that describes moving both the database and logs using sp_detach and then sp_attach. What is the best way just to move the logs to another drive on the same server, and that keeps the databases in their original location?
Thanks.
Thursday, January 24, 2008 5:15 PM
Answers
-
Yes you can move the log files to another drive using detach and attach procedures. Detach\Attach works fine only thing you need to note down is the default databases. Before you perform detach\attach operation just note down the list of all the logins and their default databases, because once you reattach it the default databases of the logins will get changed and hence there will be login failure in most cases.
- Note down default dbs for all your logins
- detach your dbs
- move it another location
- attach it
- compare the logins with step 1 and change it if the default dbs have changed.
http://sql-articles.com/index.php?page=articles/msysdb.htm
http://support.microsoft.com/kb/224071
- DeepakThursday, January 24, 2008 5:26 PM
All replies
-
Yes you can move the log files to another drive using detach and attach procedures. Detach\Attach works fine only thing you need to note down is the default databases. Before you perform detach\attach operation just note down the list of all the logins and their default databases, because once you reattach it the default databases of the logins will get changed and hence there will be login failure in most cases.
- Note down default dbs for all your logins
- detach your dbs
- move it another location
- attach it
- compare the logins with step 1 and change it if the default dbs have changed.
http://sql-articles.com/index.php?page=articles/msysdb.htm
http://support.microsoft.com/kb/224071
- DeepakThursday, January 24, 2008 5:26 PM -
Hi,
Follow below steps:
http://support.microsoft.com/kb/224071
Moving the tempdb database
You can move tempdb files by using the ALTER DATABASE statement.- Determine the logical file names for the tempdb database by using
sp_helpfile as follows:
use tempdb go sp_helpfile go
- Use the ALTER DATABASE statement, specifying the logical file name as follows:
use master go Alter database tempdb modify file (name = tempdev, filename = 'E:\Sqldata\tempdb.mdf') go Alter database tempdb modify file (name = templog, filename = 'E:\Sqldata\templog.ldf') go
Message 1File 'tempdev' modified in sysaltfiles. Delete old file after restarting SQL Server.Message 2File 'templog' modified in sysaltfiles. Delete old file after restarting SQL Server. - Using sp_helpfile in tempdb will not confirm these changes until you restart SQL Server.
- Stop and then restart SQL Server.
http://sql-bi-dev.blogspot.com.au/2010/06/moving-database-files-from-one-drive-to.html
Thanks Shiven:) If Answer is Helpful, Please Vote
- Edited by Shivendoo Kumar Dubey Monday, August 13, 2012 4:53 AM
- Proposed as answer by Shivendoo Kumar Dubey Monday, August 13, 2012 4:55 AM
- Unproposed as answer by Donia Strand Monday, September 10, 2012 4:22 PM
Monday, August 13, 2012 4:53 AM - Determine the logical file names for the tempdb database by using
sp_helpfile as follows: