SMS.SQL
资源名称:MSDN_VC98.zip [点击查看]
上传用户:bangxh
上传日期:2007-01-31
资源大小:42235k
文件大小:2k
源码类别:
Windows编程
开发平台:
Visual C++
- /*
- ** SMS.SQL
- **
- ** Allocate disk space for database devices that will
- ** be used for the database and for the log.
- ** Make sure that you have VDEVNO 30 and 31 available.
- ** If you need to create these devices on another location
- ** other than "C:MSSQLDATA", edit the PHYSNAME parameter
- ** to reflect the new location.
- ** Remember that DISK INIT allocates disk space in 2k pages.
- **
- */
- USE master
- /*
- ** Check to see if SMSdata_dev and SMSlog_dev
- ** devices exists. Then delete them, but first
- ** delete the database that may exist on the device.
- */
- IF EXISTS ( SELECT name
- FROM sysdevices
- WHERE name IN ('SMSdemo_dev', 'SMSDMlog_dev'))
- BEGIN
- DROP DATABASE SMSdemo
- EXEC sp_dropdevice SMSdemo_dev, DELFILE
- EXEC sp_dropdevice SMSDMlog_dev, DELFILE
- END
- /* Create the devices. */
- DISK INIT
- NAME = 'SMSdemo_dev',
- PHYSNAME = 'C:MSSQLDATASMSDemo.DAT',
- VDEVNO = 30,
- SIZE = 23040
- IF @@error = 0
- BEGIN
- RAISERROR('Device: SMSdemo_dev created successfully', 10, 1)
- END
- DISK INIT
- NAME = 'SMSDMlog_dev',
- PHYSNAME = 'C:MSSQLDATASMSDMLOG.DAT',
- VDEVNO = 31,
- SIZE = 5120
- IF @@error = 0
- BEGIN
- RAISERROR('Device: SMSDMlog_dev created successfully', 10, 1)
- END
- GO
- /*
- ** This section will create the database.
- **
- */
- IF EXISTS ( SELECT name
- FROM sysdatabases
- WHERE name = 'SMSdemo' ) -- Checks to see if SMSdemo db exists.
- BEGIN
- DROP DATABASE SMSdemo
- END
- CREATE DATABASE SMSdemo -- Creates the SMSdemo database.
- ON SMSdemo_dev = 45
- LOG ON SMSDMlog_dev = 10
- FOR LOAD
- GO
- /*
- ** This section will load the database.
- ** It is also depends on the SMSdmp.dat file
- ** to be located in MSSQLBACKUP directory.
- **
- */
- LOAD DATABASE SMSdemo FROM DISK='C:MSSQLBACKUPSMSdmp.dat'
- WITH STATS = 5