SQL Script to attach a database

note: this script detaches it first

 

 EXEC sp_detach_db @dbname = 'dbnametoattach'
EXEC sp_attach_single_file_db @dbname = 'dbnametoattach', @physname = 'c:\yourdirectory\dbnametoattach.mdf'

 

- Dan Lewis