home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / sdk / sysmgmt / sms / demodb / sms.sql < prev    next >
Encoding:
Text File  |  1996-10-15  |  1.9 KB  |  87 lines

  1. /*
  2. **         SMS.SQL
  3. **
  4. **  Allocate disk space for database devices that will
  5. **  be used for the database and for the log.
  6. **  Make sure that you have VDEVNO 30 and 31 available.
  7. **  If you need to create these devices on another location
  8. **  other than "C:\MSSQL\DATA", edit the PHYSNAME parameter
  9. **  to reflect the new location.
  10. **  Remember that DISK INIT allocates disk space in 2k pages.
  11. **
  12. */
  13.  
  14. USE master
  15.  
  16. /*
  17. **    Check to see if SMSdata_dev and SMSlog_dev
  18. **    devices exists. Then delete them, but first
  19. **    delete the database that may exist on the device.
  20. */
  21.  
  22. IF EXISTS ( SELECT name
  23.             FROM sysdevices
  24.             WHERE name IN ('SMSdemo_dev', 'SMSDMlog_dev'))
  25. BEGIN
  26.     DROP DATABASE SMSdemo
  27.     EXEC sp_dropdevice SMSdemo_dev, DELFILE
  28.     EXEC sp_dropdevice SMSDMlog_dev,  DELFILE
  29. END
  30.  
  31. /*  Create the devices.  */
  32.  
  33. DISK INIT
  34.   NAME =      'SMSdemo_dev',
  35.   PHYSNAME =  'C:\MSSQL\DATA\SMSDemo.DAT',
  36.   VDEVNO =    30,
  37.   SIZE =      23040
  38.  
  39.     IF @@error = 0
  40.     BEGIN
  41.         RAISERROR('Device: SMSdemo_dev created successfully', 10, 1)
  42.     END
  43.  
  44. DISK INIT
  45.   NAME =      'SMSDMlog_dev',
  46.   PHYSNAME =  'C:\MSSQL\DATA\SMSDMLOG.DAT',
  47.   VDEVNO =    31,
  48.   SIZE =      5120
  49.  
  50. IF @@error = 0
  51.     BEGIN
  52.         RAISERROR('Device: SMSDMlog_dev created successfully', 10, 1)
  53.     END
  54. GO
  55.  
  56.  
  57. /*
  58. **   This section will create the database.
  59. **
  60. */
  61.  
  62. IF EXISTS ( SELECT name
  63.             FROM sysdatabases
  64.             WHERE name = 'SMSdemo' ) -- Checks to see if SMSdemo db exists.
  65. BEGIN
  66.     DROP DATABASE SMSdemo
  67. END
  68.  
  69. CREATE DATABASE   SMSdemo    -- Creates the SMSdemo database.
  70.   ON        SMSdemo_dev = 45
  71.   LOG ON    SMSDMlog_dev  = 10
  72.   FOR LOAD
  73. GO
  74.  
  75.  
  76. /*
  77. **   This section will load the database.
  78. **   It is also depends on the SMSdmp.dat file
  79. **   to be located in \MSSQL\BACKUP\ directory.
  80. **
  81. */
  82.  
  83.  
  84. LOAD DATABASE SMSdemo FROM DISK='C:\MSSQL\BACKUP\SMSdmp.dat'
  85.     WITH STATS = 5
  86.  
  87.