Discussion Locked

Moving a SQL Database to another drive

0 helpful
11 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I am a novice using SQL server, and I am in need of some assistance. I am a consultant that is trying to "clean up" a network for a client, however, when SQL was installed the databases were created on the root drive. What is the best way to migrate the databases to another partition on the same server? What about moving the database to another server?

Thanks in advance.

11 replies

by mtnsqs

Go to Miscrosoft site and search for Q181602

basically you mirror the Db to the new location, make the mirror the primarmy and break the mirror

by ohjani

which SQL Server version are u using? the following option is only available for SQL 7.0

stop your SQL server services, move the database MDF and LDF files to your destination folder/drive. start your SQL Server, run the following script from the Query Analyser. remember to replace the DB name and location to your specification.

***************************************

CREATE DATABASE XXXXDBNameXXXX
ON PRIMARY
(
FILENAME = 'd:\mssql7\data\XXXX_Data.mdf',
SIZE = 10,
MAXSIZE= 50,
FILEGROWTH = 1%
)
LOG ON
(
FILENAME = 'd:\mssql7\data\XXXX_Log.ldf',
SIZE = 5MB,
MAXSIZE = 25MB,
FILEGROWTH = 1%
)
For ATTACH
GO

**************************************

by jmiller1

To move a database's location in SQL 7.0:

1. In Query Analyzer: execute sp_detech_db (without the brackets).

2. Move the .mdf and .ldf files to their new location.

3. In Query Analyzer: execute sp_attach_db 'dbname', 'path tomdb file', 'path to ldf file'

by pennyc

One simple way to move the MDF file to another server is to backup the data using the BACKUP option through enterprise manager. Then, move the BAK file to new location and perform the RESTORE Function. Once the file is restored, you can delete theMDF from its original location. This is a down and dirty approach... Hope it helps.

by jmiller1

Can you give a reason as to why these answers were rejected? It seems to me that any one of these methods would be sufficient to do what you ask.

jm

This discussion is closed to new replies.