Moving SQL Server data files

  • Hi,

    I want to move the database data files and log files from the C drive to the D drive. I found this article, http://support.microsoft.com/default.aspx/kb/224071. But it is thowing this error - Cannot detach the database 'mydb' because it is currently in use.

    This is what I tried.

    --Detach the database.

    --Next, copy the data and log files from the current location to the new location.

    --Re-attach the database pointing to the files in the new location.

    --Verify the change in file locations using sp_helpfile

    use master

    go

    sp_detach_db 'mydb'

    go

    use master

    go

    sp_attach_db 'mydb','D:\Sqldata\mydb_data.mdf','D:\Sqldata\mydb_log.ldf'

    go

    use mydb go

    sp_helpfile

    go

  • Senthil - In Enterprise Manager - check under Management - Current Activity - Locks/Object - to see what processes are running under "mydb" - since you're trying to detach it I assume it's not critical to any production environment right now - so you can Kill Process(es) & try again...







    **ASCII stupid question, get a stupid ANSI !!!**

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply