Move a Database to a new Location

A database data or log file can be moved from one location to another using the following steps:
— 1) Detach the Database
EXEC sp_detach_db test
— 2) Move the file that was detached to the new location
— 3) Attach the Database from the new location
EXEC sp_attach_db @dbname = N’test’,
@filename1 = N’c:\foo\test_data.mdf’,
@filename2 = N’c:\foo\test_log.ldf’
For more details regarding moving database files including Model, MSDB and TEMPDB refer to