Category Archives: Database

One of those clean-up tasks we come across in development severs is to move database mdf and ldf files to a new location. SQL Server isn’t as GUI-friendly yet to allow one to just change the paths on database properties. I have tried this out in SQL Server 2008, but the method must essentially be the same in 2005 and 2000 versions also.

What we have to do is this.
– Detach the Database
– Move the files
– Attach the database with the new location

Detach

1

2

3

usemaster

go

sp_detach_db DB_To_Move

Instead of “use master”, you can just set the query window drop-down to any DB other than DB_To_Move

Now, you need to move the files from its current location to wherever you need it to be (say, d:\data\)