Search
  Home
  Articles
  Backup
  Books
  Certification
  FAQ
  Products
  Replication
  Scripts
  Seminars
  Training
  TSQL

MSDN Fourms
Philippine SSUG

  Resume

MHS Enterprises
FilAm Software
AcrylicAcetate.com
Bargain Humidors
Western Humidor



How can I move a SQL Server device from one disk to another, or rename it?

There are two ways with SQL 6.5 :-
  1. Use device mirroring. Mirror the device to the "new" location and then break the mirror and delete the old device. This method does not need SQL downtime and can be done via the gui or via TSQL.
  2. Use the sp_movedevice sp that is documented in the Books-Online - just cut and paste this into an ISQLW session and run it to create the sp (it doesn't exist by default). After making the change stop SQL Server, physically move the device, then restart it. Therefore this method requires downtime, but it is faster as using OS level commands is faster than SQL mirroring.

All that sp_movedevice does is update the phyname in the sysdevices table.

Note that the above method works for all USER databases. If you want to move master this way, then note that the phyname parameter in sysdevices is only for documentation - you might as well change it anyway to keep things in line. The actual method SQL uses for locating the master device is by looking in the registry :-

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSSQLServer\MSSQLServer\Parameters\SQLArg0

So it is the value in this key that needs amending.

For SQL 7.0 you can use :-

sp_detach_db ...
<move devices physically>
sp_attach_db ...

For details on the stored-proc parameters see the SQL Books online.

Michael R. Hotek

All content on this site, except where noted, represents an original work of Michael R. Hotek and is protected by applicable copyright laws. The SQL Server FAQ is the sole work of Neil Pike. No page, portion of a page, or download may be used for commercial purposes in whole or in part without the express, written permission of the applicable author.