Advertisement
Guest User

Untitled

a guest
Apr 19th, 2019
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQL 1.38 KB | None | 0 0
  1. --1
  2. INSERT INTO SalesLT.Product (Name, ProductNumber, StandardCost, ListPrice, ProductCategoryID, SellStartDate)
  3. VALUES ('LED Lightsh', 'LT-L123h', 2.56, 12.99, 37, GETDATE())
  4.  
  5. SELECT SCOPE_IDENTITY() AS ProductID;
  6.  
  7. --2
  8. INSERT INTO SalesLT.ProductCategory (ParentProductCategoryID, Name)
  9. VALUES
  10. (4, 'Bells and Horns')
  11.  
  12. INSERT INTO SalesLT.Product (Name, ProductNumber, StandardCost,
  13.     ListPrice, ProductCategoryID, SellStartDate)
  14. VALUES
  15. ('Bicycle Bell', 'BB-RING', 2.47, 4.99, IDENT_CURRENT('SalesLT.ProductCategory'), GETDATE()),
  16. ('Bicycle Horn', 'BB-PARP', 1.29, 3.75, IDENT_CURRENT('SalesLT.ProductCategory'), GETDATE())
  17.  
  18. SELECT * FROM SalesLT.Product
  19. WHERE Name = 'Bicycle Bell' OR Name = 'Bicycle Horn'
  20.  
  21. SELECT * FROM SalesLT.ProductCategory
  22. WHERE Name = 'Bells and Horns'
  23.  
  24. --3
  25. UPDATE SalesLT.Product
  26. SET ListPrice = ListPrice * 1.10
  27. WHERE ProductCategoryID =
  28. (SELECT ProductCategoryID FROM SalesLT.ProductCategory WHERE Name = 'Bells and Horns')
  29.  
  30. --4
  31. UPDATE SalesLT.Product
  32. SET DiscontinuedDate = GETDATE()
  33. WHERE ProductCategoryID = 37
  34. AND ProductNumber <> 'LT-L123';
  35.  
  36. --5
  37. DELETE FROM SalesLT.Product
  38. WHERE ProductCategoryID =
  39.     (SELECT ProductCategoryID FROM SalesLT.ProductCategory WHERE Name = 'Bells and Horns')
  40.  
  41. DELETE FROM SalesLT.ProductCategory
  42. WHERE ProductCategoryID =
  43.     (SELECT ProductCategoryID FROM SalesLT.ProductCategory WHERE Name = 'Bells and Horns')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement