Move database - what are my risks

  • Hi!

    I am working with a customer and would like to move my db-files to a new disk with more space.

    I am planning to use the "detach"-"attach"-method, followed by the dbcc checkdb command.

    What are my risks? What are your experiences?

    Thanks!

  • Stuff could break during the process, so you should make a backup before you do this, validate that the backup is good (by restoring it somewhere) and then make the move. Other than that, it's a relatively safe operation as these things go. But you can't go wrong being paranoid.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

  • Make sure that the same account that you were using to connect to SQL Server to do the detach is the same account you use when you log on to the server to do the actual file copy/move. The engine sets very restrictive permissions on the files when you detach a database.

  • if you use detach\attach you may end up with a different dbid which could affect the default database assigned to users, plus the owner of the database will change to whoever attaches it.

    I would use the alter database method.

    backup db (for safety)

    offline database

    Alter database [dbname] modify file (name = [logical file name] , filename = N'new location\dbname.mdf')

    online database

    ---------------------------------------------------------------------

  • Very good input!

    But this db only has one user. As long as i attach/detach with that user it should be safe?

Viewing 5 posts - 1 through 4 (of 4 total)

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