fork download
  1. CREATE TABLE Vehicle_Type
  2. (
  3. TypeID char (3) not null PRIMARY KEY,
  4. [Description] varchar (100) not null
  5. );
  6. GO
  7.  
  8. INSERT into Vehicle_Type VALUES
  9. ('TT','Tracter Trailor'),
  10. ('ST','Semi-Tracter Trailor');
  11. GO
  12.  
  13. SELECT* from Vehicle_Type
  14. GO
  15.  
  16. CREATE TABLE Maintenance_Code
  17. (
  18. Maintenance_Type_ID varchar (5) not null PRIMARY KEY,
  19. [Description] varchar (100) not null
  20. );
  21. GO
  22.  
  23. INSERT INTO Maintenance_Code VALUES
  24. ('MOC4','Oil Change'),
  25. ('MHR9','Hose Replacement'),
  26. ('MTR5','Tire Ratation'),
  27. ('MAB8','Alignment & Balancing Tires');
  28. GO
  29.  
  30. SELECT * from Maintenance_Code
  31. GO
  32.  
  33. CREATE TABLE Maintenance_Descriptions
  34. (
  35. Maintenance_Type_ID varchar (5) not null PRIMARY KEY
  36. FOREIGN KEY REFERENCES Maintenance_Code(Maintenance_Type_ID),
  37. Level_Code varchar (10) not null,
  38. Average_Hours_Required varchar (5) not null,
  39. Days_Between_Recommended_Maintenance int not null,
  40. Maximum_Days_Between_Maintenance int not null
  41. );
  42. GO
  43.  
  44. INSERT INTO Maintenance_Descriptions VALUES
  45. ('MOC4','LvL1','1.25','90','120'),
  46. ('MHR9','LvL2','3.5','180','200'),
  47. ('MTR5','LvL3','2.0','180','210'),
  48. ('MAB8','LvL4','5.30','180','210');
  49. GO
  50.  
  51. SELECT* from Maintenance_Descriptions
  52. GO
  53.  
  54. CREATE TABLE Vehicles
  55. (VIN_Number varchar (17) not null PRIMARY KEY,
  56. TypeID char (3) not null
  57. FOREIGN KEY REFERENCES Vehicle_Type(TypeID),
  58. Class_Code varchar (6) not null,
  59. Put_Into_Service_Date date not null,
  60. Gross_Weight varchar (7) not null,
  61. Milleage varchar (9) not null,
  62. Purchase_Price varchar (9) not null,
  63. Accumulated_Depreciation varchar (9) not null,
  64. Taken_Out_Of_Service date,
  65. Capacity varchar (20) not null);
  66. GO
  67.  
  68. INSERT INTO Vehicles VALUES
  69. ('2HNYD28478H501589','ST','CL7GVW','2000-04-02','58,510','30,004','$65,350','$23,314','2010-04-30','45,000 53X13.6X102'),
  70. ('2T1FF28PX1C539447','TT','CL5GVW','2001-05-29','47,850','89,347','$57,950','$17,964','2012-06-01','97,000 55X15.25X102');
  71. GO
  72.  
  73. SELECT * from Vehicles
  74. GO
  75.  
  76. CREATE TABLE Vehicle_Maintenance
  77. (
  78. VIN_Number varchar (17) not null,
  79. PartsID varchar (10) not null,
  80. Maintenance_Type_ID varchar (5) not null,
  81. Put_Into_Service_Date date not null,
  82. Last_Maintenance_Date date not null,
  83. Next_Scheduled_Maintenance date not null,
  84. Under_Warranty_Flag char (1) not null
  85. );
  86. GO
  87.  
  88. INSERT INTO Vehicle_Maintenance VALUES
  89. ('2HNYD28478H501589','QH1300AS','MOC4','2011-06-15','2012-01-31','2013-01-31','Y'),
  90. ('2T1FF28PX1C539447','1590002','MHR9','2011-02-22','2012-03-25','2012-12-01','Y');
  91. GO
  92.  
  93. select * from Vehicle_Maintenance;
  94. GO
  95.  
  96. CREATE TABLE Tire_Maintenance
  97. (
  98. Barcode varchar (17) not null PRIMARY KEY,
  99. Maintenance_Type_ID varchar (5) not null
  100. FOREIGN KEY REFERENCES Maintenance_Code(Maintenance_Type_ID),
  101. TypeID char (3) not null
  102. FOREIGN KEY REFERENCES Vehicle_Type(TypeID),
  103. Manufacture_ID varchar (15) not null,
  104. Put_Into_Service_Date date not null,
  105. Rotated_Scheduled_Date date not null,
  106. Last_Rotated_Date date not null,
  107. Disposal_Date date not null
  108. );
  109. GO
  110.  
  111. INSERT INTO Tire_Maintenance VALUES
  112. ('79008 40228','MTR5','ST','GoodYr2002','2006-10-06','2012-08-10','2012-05-12','2012-05-17'),
  113. ('96018 13820','MAB8','TT','Yukon2010','2009-07-02','2012-05-31','2012-02-28','2012-02-10');
  114. GO
  115.  
  116. SELECT * from Tire_Maintenance
  117. GO
  118.  
  119. CREATE TABLE Maintenance_Work_Order
  120. (
  121. Work_Order_ID varchar (5) not null PRIMARY KEY,
  122. VIN_Number varchar (17) not null
  123. FOREIGN KEY REFERENCES Vehicles (VIN_Number),
  124. Maintenance_Type_ID varchar (5) not null
  125. FOREIGN KEY REFERENCES Maintenance_Code(Maintenance_Type_ID),
  126. Assignment_To varchar (9) not null,
  127. Date_Started date not null,
  128. Date_Completed date not null,
  129. [Hours] varchar (7) not null
  130. );
  131. GO
  132.  
  133.  
  134. INSERT INTO Maintenance_Work_Order VALUES
  135. ('H1000','2HNYD28478H501589','MOC4','Blue Team','2012-05-09','2012-05-11','3.0'),
  136. ('H1001','2T1FF28PX1C539447','MHR9','Black Team','2012-04-28','2012-04-30','2.75');
  137. GO
  138.  
  139. select * from Maintenance_Work_Order
  140. GO
  141.  
  142. CREATE TABLE Vendors
  143. (
  144. Vendor_ID varchar (7) not null PRIMARY KEY
  145. FOREIGN KEY REFERENCES Vendors (Vendor_ID),
  146. Name varchar (10)not null,
  147. Order_Address varchar (5) not null,
  148. Order_Street varchar (10) not null,
  149. Order_City varchar (15) not null,
  150. Order_State char (2) not null,
  151. Order_Zip int not null,
  152. Order_Contact char (15) not null,
  153. Order_Phone_Number varchar (15) not null,
  154. Order_Fax_Number varchar (15),
  155. Billing_Address varchar (5) not null,
  156. Billing_Street varchar (10) not null,
  157. Billing_City varchar (15) not null,
  158. Billing_State char (2) not null,
  159. Billing_Zip int not null,
  160. Billing_Contact char (15) not null,
  161. Billing_Phone_Number varchar(15) not null,
  162. Billing_Fax_Number varchar (15) not null
  163. );
  164. GO
  165.  
  166.  
  167. INSERT into Vendors VALUES
  168. ('SAP8','Sears','5178','Pearl Road','Cleveland','OH','44129','Mary Kay','(216)351-3279','(216)351-7500','6600','Bessemer Avenue','Cleveland','OH','44127','John Smith','(216)341-7140','(216)429-3523'),
  169. ('NA00','NAPA','3141','Superior Avenue','Cleveland','OH','44114','Andrew Linder','(216)771-1515','(216)398-9800','6600','Bessemer Avenue','Cleveland','OH','44127','John Smith','(216)341-7140','(216)429-3523')
  170. GO
  171.  
  172. select*from Vendors
  173. GO
  174.  
  175.  
Runtime error #stdin #stdout 0s 3008KB
stdin
select * from Names WHERE Fname = 'John' AND Lname = 'Doe';
stdout
Standard output is empty