DISK REINIT Statement

Restores the device entries to the system tables when a device exists (the file is present) and the entry in the sysdevices table no longer exists. This occurs after a damaged master database is restored and the master database is incomplete (databases and devices were added or altered since the last backup of the master database). This is the first step for restoring access to user databases. The DISK REFIT statement completes the recovery.

Syntax

DISK REINIT
    NAME = 'logical_name',
    PHYSNAME = 'physical_name',
    VDEVNO = virtual_device_number,
    SIZE = number_of_2K_blocks
    [, VSTART = virtual_address]

where

NAME
Specifies the logical name of the database device. Logical names must correspond to the rules for identifiers and must be enclosed with single quotation marks ('). This name is used in the CREATE DATABASE and ALTER DATABASE statements.
PHYSNAME
Specifies the drive letter, full path, and filename of the database device file that already exists. Physical name must follow the rules for your operating system's paths and filenames. It must be enclosed with quotation marks (').
VDEVNO
Specifies the virtual device number. It must be unique among database devices used by SQL Server. Values can be from 1 through 255; 0 is reserved for the MASTER database device.

Note NAME, PHYSNAME, and VDEVNO do not have to be identical to the device as it was originally created; however, the SIZE parameter must match.

SIZE
Specifies the size, in 2K blocks, of the database device. The minimum usable size is 512 2K blocks (1 MB).
VSTART
Specifies the starting virtual address or the starting offset in 2K blocks. The value for VSTART should be 0 (the default). Reset it only if instructed to do so.

Remarks

DISK REINIT is very similar to DISK INIT but does not initialize the disk space.

Caution If you give DISK REINIT incorrect information about sizes and attempt to run update operations, you can permanently corrupt your data. SQL Server warns you of potential problems if it can, but be sure to run the suggested checks after issuing DISK REINIT and DISK REFIT.

If problems occur, you probably did not run DISK REINIT or ran it with inaccurate information. If you recognize discrepancies in the sysusages table, correct them. Correct the sysdevices table by rerunning DISK REINIT and then reissuing DISK REFIT. The system administrator must be in the master database to use DISK REINIT.

For more information about using DISK REINIT, see the Microsoft SQL Server Administrator's Companion.

Permission

DISK REINIT permission defaults to the system administrator and is not transferable.

Example

DISK REINIT must be run for each device of the database prior to running DISK REFIT.

DISK REINIT
    NAME = 'DEVICE5',
    PHYSNAME = 'c:\sqldata\device5.dat',
    VDEVNO = 5,
    SIZE = 25600

DISK REINIT
    NAME = 'DEVICE6',
    PHYSNAME = 'd:\sqldata\device6.dat',
    VDEVNO = 6,
    SIZE = 25600

Once all devices have been created, run DISK REFIT.

DISK REFIT

See Also

ALTER DATABASE DISK INIT
CREATE DATABASE DISK REFIT
DBCC sp_helpdevice