home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 February / CHIP_2_98.iso / software / pelne / optionp / rds.cab / sampleemp.sql < prev    next >
Text File  |  1997-08-14  |  5KB  |  132 lines

  1. set quoted_identifier on
  2. GO
  3.  
  4. use master
  5. GO
  6.  
  7. if exists (select * from sysdatabases where name = 'AddrBookDB')
  8.     drop database AddrBookDB
  9. GO
  10.  
  11. create database AddrBookDb on default = 1
  12. GO
  13.  
  14. use AddrBookDB
  15. GO
  16.  
  17.  
  18. /****** Object:  User 'adcdemo' ******/
  19. if not exists (select * from master..syslogins where name = 'adcdemo')
  20.     EXEC sp_addlogin 'adcdemo', 'adcdemo', 'AddrBookDB'
  21. GO
  22. EXEC sp_adduser 'adcdemo'
  23. GO
  24.  
  25. /****** Object:  Table dbo.Employee ******/
  26. if exists (select * from sysobjects where id = object_id('dbo.Employee') and sysstat & 0xf = 3)
  27.     drop table "dbo"."Employee"
  28. GO
  29.  
  30. /****** Object:  Table dbo.Employee  ******/
  31.  
  32. CREATE TABLE dbo.Employee (
  33.     ID int IDENTITY (1010, 10) NOT NULL ,
  34.     FirstName varchar (30) NOT NULL ,
  35.     LastName varchar (30) NOT NULL ,
  36.     Name varchar (60) NULL,
  37.     Title varchar (20) NULL,
  38.     Type varchar (20) NULL,
  39.     Email varchar (20) NULL,
  40.     ManagerEmail varchar (20) NULL,
  41.     Building varchar (30) NULL,
  42.     Room varchar (20) NULL,
  43.     Phone varchar (20) NULL,
  44.     CONSTRAINT PK___1__10 PRIMARY KEY  CLUSTERED 
  45.     (
  46.         ID
  47.     )
  48. )
  49. GO
  50.  
  51. GRANT  REFERENCES ,  SELECT ,  INSERT ,  DELETE ,  UPDATE  ON "Employee"  TO "public"
  52. GO
  53.  
  54. -- Populate the table with sample data
  55.  
  56. insert Employee values ('Amy' ,'Anderson' ,'Anderson, Amy' ,'Purchase Manager' ,'full-time' ,'amya' ,'jamesa' ,'6' ,'2021' ,'555-7132')
  57. go
  58.  
  59. insert Employee values ('Karen' ,'Berge' ,'Berge, Karen' ,'Program Manager' ,'full-time' ,'karenb' ,'jamesa' ,'4' ,'1020' ,'555-7233')
  60. go
  61.  
  62. insert Employee values ('Jan' ,'Trabandt' ,'Trabandt, Jan' ,'Program Manager' ,'full-time' ,'jantr' ,'michaelc' ,'5' ,'2214' ,'555-3743')
  63. go
  64.  
  65. insert Employee values ('Viki' ,'Parrott' ,'Parrott, Viki' ,'Sales Manager' ,'full-time' ,'vikip' ,'amyan' ,'1' ,'1205' ,'555-5327')
  66. go
  67.  
  68. insert Employee values ('Bill' ,'Sornsin' ,'Sornsin, Bill' ,'Account Executive' ,'full-time' ,'billso' ,'darlener' ,'3' ,'2003' ,'555-2757')
  69. go
  70.  
  71. insert Employee values ('Rich' ,'Andrews' ,'Andrews, Rich' ,'Sales Representative' ,'full-time' ,'richand' ,'josel' ,'6' ,'1023' ,'555-2701')
  72. go
  73.  
  74. insert Employee values ('Max' ,'Benson' ,'Benson, Max' ,'Account Executive' ,'full-time' ,'maxb' ,'kimy' ,'4' ,'1586' ,'555-2715')
  75. go
  76.  
  77. insert Employee values ('Barbara' ,'Hoffman' ,'Hoffman, Barbara' ,'District Sales Manager' ,'full-time' ,'barbh' ,'lauraj' ,'5' ,'2295' ,'555-2711')
  78. go
  79.  
  80. insert Employee values ('Laura' ,'Jennings' ,'Jennings, Laura' ,'Regional Sales Director' ,'full-time' ,'lauraj' ,'bobm' ,'1' ,'2106' ,'555-2712')
  81. go
  82.  
  83. insert Employee values ('Beverly' ,'Jones' ,'Jones, Beverly' ,'Marketing Manager' ,'full-time' ,'beverlyj' ,'lauraj' ,'3' ,'1242' ,'555-2705')
  84. go
  85.  
  86. insert Employee values ('Brent' ,'Jones' ,'Jones, Brent' ,'Senior Accountant' ,'full-time' ,'brentk' ,'jamesa' ,'6' ,'2178' ,'555-2708')
  87. go
  88.  
  89. insert Employee values ('April' ,'LaMonte' ,'LaMonte, April' ,'Sales Representative' ,'full-time' ,'aprilla' ,'josel' ,'4' ,'1814' ,'555-2702')
  90. go
  91.  
  92. insert Employee values ('Jose' ,'Lugo' ,'Lugo, Jose' ,'Sales Manager' ,'full-time' ,'josel' ,'barbh' ,'5' ,'1250' ,'555-2707')
  93. go
  94.  
  95. insert Employee values ('Steve' ,'Masters' ,'Masters, Steve' ,'Program Manager' ,'full-time' ,'stevemas' ,'michaelc' ,'1' ,'2086' ,'555-2709')
  96. go
  97.  
  98. insert Employee values ('Thom' ,'McCann' ,'McCann, Thom' ,'Sales Representative' ,'full-time' ,'thommc' ,'josel' ,'3' ,'2122' ,'555-2704')
  99. go
  100.  
  101. insert Employee values ('Nina' ,'Roberts' ,'Roberts, Nina' ,'Account Executive' ,'full-time' ,'ninaro' ,'kimy' ,'6' ,'1158' ,'555-2710')
  102. go
  103.  
  104. insert Employee values ('Sharon' ,'Swanson' ,'Swanson, Sharon' ,'Sales Representative' ,'full-time' ,'sharons' ,'josel' ,'4' ,'1194' ,'555-2706')
  105. go
  106.  
  107. insert Employee values ('Stephen' ,'Thomas' ,'Thomas, Stephen' ,'Account Executive' ,'full-time' ,'thomas' ,'kimy' ,'5' ,'2230' ,'555-2713')
  108. go
  109.  
  110. insert Employee values ('Kevin' ,'Yim' ,'Yim, Kevin' ,'Account Executive' ,'full-time' ,'keviny' ,'kimy' ,'1' ,'2266' ,'555-2714')
  111. go
  112.  
  113. insert Employee values ('Kim' ,'Yoshida' ,'Yoshida, Kim' ,'Account Manager' ,'full-time' ,'kimy' ,'barbh' ,'3' ,'1102' ,'555-2703')
  114. go
  115.  
  116.  
  117. -- Run a stored procedure to verify the creation of the table and metadata
  118.  
  119. sp_help employee
  120. go
  121.  
  122. -- Do a simple select statement to verify the population of the database table
  123. -- Should return 20 rows of data
  124.  
  125. select LastName, FirstName, Email from employee
  126. go
  127.  
  128. -- Grant read and write permissions to public for the employee table (updates)
  129.  
  130. grant all on employee to public
  131. go
  132.