useful things about data, databases, data warehouse and related stuff. The opinions expressed in this blog are mine alone. They may not necessarily reflect that of my employers and customers - both past or present. The comments left by the reviewers are theirs alone and may not reflect my opinion whether implied or not. None of the advice is warranted to be free of errors and omission. Please use at your own risk and after thorough testing in your environment.
How to move SQL Server database files to different location
(Works for SQL 2005/2008)
In case you need to move database files (data or log) to new location one way to do it is to detach the database, move the files to location and attach it back
1)Detach database: Detaching a database removes it from the instance of the Microsoft SQL Server Database Engine but leaves intact the database, with its data files and transaction log files. Following script can be used
2)Move files to new location: You can manually copy the files but I prefer to use XCOPY. Here is how