sqlserver7.sql 18 KB

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