In this blog you will find ASP.NET 3.5 articles and some code samples. These code samples are created by me and should be working. Thanks for visiting my blog! Happy Dot Netting

Friday, September 18, 2009

Attach and Detach the database by SQL

-- 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