sqlserver.sql 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. use monotest;
  2. -- =================================== OBJECT NUMERIC_FAMILY============================
  3. -- TABLE : NUMERIC_FAMILY
  4. -- data with id > 6000 is not gaurenteed to be read-only.
  5. if exists (select name from sysobjects where
  6. name = 'numeric_family' and type = 'U')
  7. drop table numeric_family;
  8. go
  9. create table numeric_family (
  10. id int PRIMARY KEY NOT NULL,
  11. type_bit bit NULL,
  12. type_tinyint tinyint NULL,
  13. type_smallint smallint NULL,
  14. type_int int NULL,
  15. type_bigint bigint NULL,
  16. type_decimal1 decimal(38,0) NULL,
  17. type_decimal2 decimal(10,3) NULL,
  18. type_numeric1 numeric(38,0) NULL,
  19. type_numeric2 numeric(10,3) NULL,
  20. type_money money NULL,
  21. type_smallmoney smallmoney NULL,
  22. type_float real NULL,
  23. type_double float NULL,
  24. type_autoincrement int identity (2, 3));
  25. go
  26. grant all privileges on numeric_family to monotester;
  27. go
  28. insert into numeric_family (id, type_bit, type_tinyint, type_smallint, type_int, type_bigint, type_decimal1, type_decimal2, type_numeric1, type_numeric2, type_money, type_smallmoney, type_float, type_double)
  29. values (1, 1, 255, 32767, 2147483647, 9223372036854775807, 1000, 4456.432, 1000, 4456.432, 922337203685477.5807, 214748.3647, 3.40E+38, 1.79E+308);
  30. insert into numeric_family (id, type_bit, type_tinyint, type_smallint, type_int, type_bigint, type_decimal1, type_decimal2, type_numeric1, type_numeric2, type_money, type_smallmoney, type_float, type_double)
  31. values (2, 0, 0, -32768, -2147483648, -9223372036854775808, -1000, -4456.432, -1000, -4456.432, -922337203685477.5808, -214748.3648, -3.40E+38, -1.79E+308);
  32. insert into numeric_family (id, type_bit, type_tinyint, type_smallint, type_int, type_bigint, type_decimal1, type_decimal2, type_numeric1, type_numeric2, type_money, type_smallmoney, type_float, type_double)
  33. values (3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
  34. insert into numeric_family (id, type_bit, type_tinyint, type_smallint, type_int, type_bigint, type_decimal1, type_decimal2, type_numeric1, type_numeric2, type_money, type_smallmoney, type_float, type_double)
  35. values (4, null, null, null, null, null, null, null, null, null, null, null, null, null);
  36. go
  37. -- =================================== END OBJECT NUMERIC_FAMILY ========================
  38. -- =================================== OBJECT BINARY_FAMILY =========================
  39. -- TABLE : BINARY_FAMILY
  40. -- data with id > 6000 is not gaurenteed to be read-only.
  41. if exists (select name from sysobjects where
  42. name = 'binary_family' and type = 'U')
  43. drop table binary_family;
  44. go
  45. create table binary_family (
  46. id int PRIMARY KEY NOT NULL,
  47. type_binary binary (8) NULL,
  48. type_varbinary varbinary (255) NULL,
  49. type_blob image NULL,
  50. type_tinyblob image NULL,
  51. type_mediumblob image NULL,
  52. type_longblob_image image NULL,
  53. type_timestamp timestamp NULL);
  54. go
  55. grant all privileges on binary_family to monotester;
  56. go
  57. insert into binary_family (id, type_binary, type_varbinary, type_blob, type_tinyblob, type_mediumblob, type_longblob_image) values (
  58. 1,
  59. convert (binary, '5'),
  60. convert (varbinary(255), 0x303132333435363738393031323334353637383930313233343536373839004453),
  61. convert (image, 0x3256004422),
  62. convert (image, 0x3A56004422),
  63. convert (image, 0x2B87002233),
  64. convert (image, 0x4D84002332)
  65. );
  66. insert into binary_family (id, type_binary, type_varbinary, type_blob, type_tinyblob, type_mediumblob, type_longblob_image) values (
  67. 2,
  68. convert (binary, 0x0033340033303531),
  69. convert (varbinary, 0x003938373635003332313031323334),
  70. convert (image, 0x0066066697006606669706660666970666066697066606669706660666970666066697066606669706660666970666066697066606669706660666970666066697066606669706660666970666066697066606669706660666970666066697066606669706660666970666066697066606669706660666970666066697066606669706660666970666066697066606669706660666970666066697066606669706660666970666066697066606669706660666970666066697066606669706660666970666066697066606669706660666970666066697066606669706660666970666066697066606669706660666970666066697066606669706660666970666066697066606669706660666970666066698),
  71. convert (image, 0x0056334422),
  72. convert (image, 0x0087342233),
  73. convert (image, 0x0084352332)
  74. );
  75. insert into binary_family (id, type_binary, type_varbinary, type_blob, type_tinyblob, type_mediumblob, type_longblob_image) values (
  76. 3,
  77. convert (binary, ''),
  78. convert (varbinary, ''),
  79. convert (image, ''),
  80. convert (image, ''),
  81. convert (image, ''),
  82. convert (image, '')
  83. );
  84. insert into binary_family (id, type_binary, type_varbinary, type_blob, type_tinyblob, type_mediumblob, type_longblob_image) values (
  85. 4,null,null,null,null,null,null);
  86. go
  87. -- =================================== END OBJECT BINARY_FAMILY ========================
  88. -- =================================== OBJECT STRING_FAMILY============================
  89. -- TABLE : string_family
  90. -- data with id above 6000 is not gaurenteed to be read-only.
  91. if exists (select name from sysobjects where
  92. name = 'string_family' and type = 'U')
  93. drop table string_family;
  94. go
  95. create table string_family (
  96. id int PRIMARY KEY NOT NULL,
  97. type_guid uniqueidentifier NULL,
  98. type_char char(10) NULL,
  99. type_nchar nchar(10) NULL,
  100. type_varchar varchar(10) NULL,
  101. type_nvarchar nvarchar(10) NULL,
  102. type_text text NULL,
  103. type_ntext ntext NULL);
  104. go
  105. grant all privileges on string_family to monotester;
  106. go
  107. insert into string_family values (1, 'd222a130-6383-4d36-ac5e-4e6b2591aabf', 'char', N'nchभाr', 'varchar', N'nvभारतr', 'text', N'ntभाxt');
  108. insert into string_family values (2, '1c47dd1d-891b-47e8-aac8-f36608b31bc5', '0123456789', '0123456789', 'varchar ', N'nvभारतr ', 'longtext longtext longtext longtext longtext longtext longtext longtext longtext longtext longtext longtext longtext longtext longtext longtext longtext longtext longtext longtext longtext longtext longtext longtext longtext longtext longtext longtext longtext longtext ', N'ntभाxt ');
  109. insert into string_family values (3, '3c47dd1d-891b-47e8-aac8-f36608b31bc5', '', '', '', '', '', '');
  110. insert into string_family values (4, null, null, null, null, null, null, null);
  111. go
  112. -- =================================== END OBJECT STRING_FAMILY ========================
  113. -- =================================== OBJECT DATETIME_FAMILY============================
  114. -- TABLE : datetime_family
  115. -- data with id above 6000 is not gaurenteed to be read-only.
  116. if exists (select name from sysobjects where
  117. name = 'datetime_family' and type = 'U')
  118. drop table datetime_family;
  119. go
  120. create table datetime_family (
  121. id int PRIMARY KEY NOT NULL,
  122. type_smalldatetime smalldatetime NULL,
  123. type_datetime datetime NULL);
  124. grant all privileges on datetime_family to monotester;
  125. go
  126. insert into datetime_family values (1,'2037-12-31 23:59:00','9999-12-31 23:59:59:997');
  127. insert into datetime_family values (4,null,null);
  128. go
  129. -- =================================== END OBJECT DATETIME_FAMILY========================
  130. -- =================================== OBJECT EMPLOYEE ============================
  131. -- TABLE : EMPLOYEE
  132. -- data with id above 6000 is not gaurenteed to be read-only.
  133. if exists (select name from sysobjects where
  134. name = 'employee' and type = 'U')
  135. drop table employee;
  136. go
  137. create table employee (
  138. id int PRIMARY KEY NOT NULL,
  139. fname varchar (50) NOT NULL,
  140. lname varchar (50) NULL,
  141. dob datetime NOT NULL,
  142. doj datetime NOT NULL,
  143. email varchar (50) NULL);
  144. go
  145. grant all privileges on employee to monotester;
  146. go
  147. insert into employee values (1, 'suresh', 'kumar', '1978-08-22', '2001-03-12', '[email protected]');
  148. insert into employee values (2, 'ramesh', 'rajendran', '1977-02-15', '2005-02-11', '[email protected]');
  149. insert into employee values (3, 'venkat', 'ramakrishnan', '1977-06-12', '2003-12-11', '[email protected]');
  150. insert into employee values (4, 'ramu', 'dhasarath', '1977-02-15', '2005-02-11', '[email protected]');
  151. go
  152. -- STORED PROCEDURES
  153. -- SP : sp_clean_employee_table
  154. if exists (select name from sysobjects where
  155. name = 'sp_clean_employee_table' and type = 'P')
  156. drop procedure sp_clean_employee_table;
  157. go
  158. create procedure sp_clean_employee_table
  159. as
  160. begin
  161. delete from employee where id > 6000;
  162. end
  163. go
  164. grant execute on sp_clean_employee_table to monotester;
  165. -- SP : sp_get_age
  166. if exists (select name from sysobjects where
  167. name = 'sp_get_age' and type = 'P')
  168. drop procedure sp_get_age;
  169. go
  170. create procedure sp_get_age (
  171. @fname varchar (50),
  172. @age int output)
  173. as
  174. begin
  175. select @age = datediff (day, dob, getdate ()) from employee where fname like @fname;
  176. return @age;
  177. end
  178. go
  179. grant execute on sp_get_age to monotester;
  180. -- =================================== END OBJECT EMPLOYEE ============================
  181. -- SP : sp_326182
  182. if exists (select name from sysobjects where
  183. name = 'sp_326182' and type = 'P')
  184. drop procedure sp_326182;
  185. go
  186. CREATE procedure sp_326182 (
  187. @param0 int out,
  188. @param1 int out,
  189. @param2 int out,
  190. @param3 int out)
  191. as
  192. begin
  193. set @param0 = 100
  194. set @param1 = 101
  195. set @param2 = 102
  196. set @param3 = 103
  197. return 2
  198. end
  199. go
  200. grant execute on sp_get_age to monotester;