-- Get all the db names from SQL server
select name from sys.databases
-- Detach the Database
sp_detach_db 'Bugtracker'
-- Attach the database
Create database bugtracker On
(filename = 'F:\SQL Files\bugtracker.mdf'),
(filename = 'F:\SQL Files\bugtracker_log.ldf')
for attach
Go