Installs a database and its devices. It must be run once for each device of the database being installed. This system stored procedure copies the system device to the hard disk (placing the system catalog tables and the transaction log on read/write media). You can leave the data device on the distribution media (usually a CD), or you can copy it to the hard disk (but it remains read-only).
sp_dbinstall database, logical_dev_name, 'physical_dev_name', size,
'devtype' [,'location']
where
If the database contains more than one data device, you must run this system stored procedure once for each device.
A location is required for the system device. It is optional for a data device (since a data device can be left on the distribution media).
Important When using sp_dbinstall, all of a database's devices must be installed.
The information required by the sp_dbinstall parameters is provided when the database is verified using sp_certify_removable.
When a database is installed using sp_dbinstall, it is set to offline. Before it can be used it must be placed online by using sp_dboption. After the database has been installed using sp_dbinstall and brought online using sp_dboption, it can be configured to suit local requirements. Users can be added, permissions can be granted, and stored procedures and views can be created. However, after the database is installed, do not attempt to perform inserts, updates, or deletes against the read-only data in the data tables.
Before the database can be used (that is, set online by using sp_dboption) all of its devices must be available. This means that if a database¾because of size¾has been distributed on several CDs with a different data device on each CD, and if the computer is equipped with only one CD drive, then as each device is installed sp_dbinstall must be provided a location parameter for all but one of the devices, so that all but one of the data devices are copied off the distribution CDs onto the computer's local hard disk. If this is done, only one CD will need to be in the CD drive when the database is used. To eliminate all need for a CD when using the database, all the data devices can be copied.
As an advanced option, if the data device has been moved to read/write media, it can be made read/write by running sp_addsegment against the device and using sp_devoption to set the readonly setting to false for that device.
You can also use this system stored procedure to install databases and devices from non-removable media.
This example installs the removable media database inventory from the distribution CD, which is located in the computer's CD-ROM drive, drive E. The system device containing the system catalog tables and the transaction log is copied to the computer's hard disk and the data device is left on the distribution media.
sp_dbinstall inventory,invsys,'e:\invsys.dat',2,'SYSTEM', 'c:\sql60\data\invsys.dat' EXEC sp_dbinstall inventory,invdata,'e:\invdata.dat',10,'DATA'
Only the system administrator can use this stored procedure.
sysdatabases, sysdevices, sysusages
sp_certify_removable | sp_dboption |
sp_create_removable | sp_dbremove |