Thursday, 23 July 2009

Detach and Attach DB

How to Detach and Attach DB:

1. Location of files are in : C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\

2. Our purpose is to move the database from C: Drive to D: Drive

3. Execute the below Procedure:

USE [master]
GO
EXEC master.dbo.sp_detach_db @dbname = N'Reporting', @keepfulltextindexfile=N'true'

4. Move the mdf and ldf files to the D: Drive Now:

5. Then Execute the below procedure to attach db:

EXEC sp_attach_db @dbname = 'Reporting',
@filename1 = 'D:\data\Reporting\Reporting.mdf',
@filename2 = 'D:\data\Reporting\Reporting_log.ldf'

No comments:

Post a Comment