sqlserver.sql 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. if exists (select name from sysdatabases where
  2. name = 'mono-test')
  3. drop database [mono-test];
  4. create database [mono-test];
  5. grant all privileges on [mono-test] to monotester;
  6. go
  7. use monotest;
  8. -- =================================== OBJECT NUMERIC_FAMILY============================
  9. -- TABLE : NUMERIC_FAMILY
  10. -- data with id > 6000 is not gaurenteed to be read-only.
  11. if exists (select name from sysobjects where
  12. name = 'numeric_family' and type = 'U')
  13. drop table numeric_family;
  14. go
  15. create table numeric_family(
  16. id int PRIMARY KEY NOT NULL,
  17. type_bit bit NULL,
  18. type_tinyint tinyint NULL,
  19. type_smallint smallint NULL,
  20. type_int int NULL,
  21. type_bigint bigint NULL,
  22. type_decimal decimal(38,0) NULL,
  23. type_numeric numeric(38,0) NULL,
  24. type_money money NULL,
  25. type_smallmoney smallmoney NULL,
  26. type_float real NULL,
  27. type_double float NULL);
  28. go
  29. grant all privileges on numeric_family to monotester;
  30. go
  31. insert into numeric_family values (1,1,255,32767,2147483647,9223372036854775807,1000,1000,922337203685477.5807,214748.3647,3.40E+38,1.79E+308);
  32. insert into numeric_family values (2,0,0,-32768,-2147483648,-9223372036854775808,-1000,-1000,-922337203685477.5808,-214748.3648,-3.40E+38,-1.79E+308);
  33. insert into numeric_family values (3,0,0,0,0,0,0,0,0,0,0,0);
  34. insert into numeric_family values (4,null,null,null,null,null,null,null,null,null,null,null);
  35. go
  36. -- =================================== END OBJECT NUMERIC_FAMILY ========================
  37. -- =================================== OBJECT BINARY_FAMILY =========================
  38. -- TABLE : BINARY_FAMILY
  39. -- data with id > 6000 is not gaurenteed to be read-only.
  40. if exists (select name from sysobjects where
  41. name = 'binary_family' and type = 'U')
  42. drop table binary_family;
  43. go
  44. create table binary_family (
  45. id int PRIMARY KEY NOT NULL,
  46. type_binary binary NULL,
  47. type_varbinary varbinary (255) NULL,
  48. type_blob image NULL,
  49. type_tinyblob image NULL,
  50. type_mediumblob image NULL,
  51. type_longblob_image image NULL);
  52. go
  53. grant all privileges on binary_family to monotester;
  54. go
  55. insert into binary_family values (1, convert (binary, '555555'), convert (varbinary, '0123456789012345678901234567890123456789012345678901234567890123456789'),
  56. convert (image, '66666666'), convert (image, '777777'),
  57. convert (image, '888888'), convert (image, '999999'));
  58. --insert into binary_family values (2,
  59. --insert into binary_family values (3,
  60. insert into binary_family values (4,null,null,null,null,null,null);
  61. go
  62. -- =================================== END OBJECT BINARY_FAMILY ========================
  63. -- =================================== OBJECT STRING_FAMILY============================
  64. -- TABLE : string_family
  65. -- data with id above 6000 is not gaurenteed to be read-only.
  66. if exists (select name from sysobjects where
  67. name = 'string_family' and type = 'U')
  68. drop table string_family;
  69. go
  70. create table string_family(
  71. id int PRIMARY KEY NOT NULL,
  72. type_guid uniqueidentifier NULL,
  73. type_char char(10) NULL,
  74. type_varchar varchar(10) NULL,
  75. type_text text NULL,
  76. type_ntext ntext NULL);
  77. go
  78. grant all privileges on string_family to monotester;
  79. go
  80. insert into string_family values (1,newid(),"char","varchar","text","ntext");
  81. insert into string_family values (4,null,null,null,null,null);
  82. go
  83. -- =================================== END OBJECT STRING_FAMILY ========================
  84. -- =================================== OBJECT DATETIME_FAMILY============================
  85. -- TABLE : datetime_family
  86. -- data with id above 6000 is not gaurenteed to be read-only.
  87. if exists (select name from sysobjects where
  88. name = 'datetime_family' and type = 'U')
  89. drop table datetime_family;
  90. go
  91. create table datetime_family (
  92. id int PRIMARY KEY NOT NULL,
  93. type_smalldatetime smalldatetime NULL,
  94. type_datetime datetime NULL);
  95. grant all privileges on datetime_family to monotester;
  96. go
  97. insert into datetime_family values (1,'2079-06-06 23:59:00','9999-12-31 23:59:59.997');
  98. insert into datetime_family values (4,null,null);
  99. go
  100. -- =================================== END OBJECT DATETIME_FAMILY========================
  101. -- =================================== OBJECT EMPLOYEE ============================
  102. -- TABLE : EMPLOYEE
  103. -- data with id above 6000 is not gaurenteed to be read-only.
  104. if exists (select name from sysobjects where
  105. name = 'employee' and type = 'U')
  106. drop table employee;
  107. go
  108. create table employee (
  109. id int PRIMARY KEY NOT NULL,
  110. fname varchar (50) NOT NULL,
  111. lname varchar (50) NULL,
  112. dob datetime NOT NULL,
  113. doj datetime NOT NULL,
  114. email varchar (50) NULL);
  115. go
  116. grant all privileges on employee to monotester;
  117. go
  118. insert into employee values (1, 'suresh', 'kumar', '1978-08-22', '2001-03-12', '[email protected]');
  119. insert into employee values (2, 'ramesh', 'rajendran', '1977-02-15', '2005-02-11', '[email protected]');
  120. insert into employee values (3, 'venkat', 'ramakrishnan', '1977-06-12', '2003-12-11', '[email protected]');
  121. insert into employee values (4, 'ramu', 'dhasarath', '1977-02-15', '2005-02-11', '[email protected]');
  122. go
  123. -- STORED PROCEDURES
  124. -- SP : sp_clean_person_table
  125. if exists (select name from sysobjects where
  126. name = 'sp_clean_employee_table' and type = 'P')
  127. drop procedure sp_clean_employee_table;
  128. go
  129. create procedure sp_clean_employee_table
  130. as
  131. begin
  132. delete from employee where id > 6000;
  133. end
  134. go
  135. -- SP : sp_get_age
  136. if exists (select name from sysobjects where
  137. name = 'sp_get_age' and type = 'P')
  138. drop procedure sp_get_age;
  139. go
  140. create procedure sp_get_age (
  141. @fname varchar (50),
  142. @age int output)
  143. as
  144. begin
  145. select @age = datediff (day, dob, getdate ()) from employee where fname like @fname;
  146. return @age;
  147. end
  148. go
  149. -- =================================== END OBJECT EMPLOYEE ============================