Advertisement
Guest User

Jimmy

a guest
Mar 19th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.89 KB | None | 0 0
  1. USE [Northwind]
  2.  
  3. --1 Create a stored Procedure show all Categories
  4. go
  5. CREATE PROCEDURE sp_Categories_Display
  6.  
  7. AS
  8. BEGIN
  9.  
  10. Select *
  11. From Categories
  12.  
  13. END
  14. Go
  15.  
  16. --2 Create a stored Procedure to search a categories by id ---------------------------
  17.  
  18. Go
  19. CREATE PROCEDURE sp_Categories_SearchID
  20. @CategoryID int
  21.  
  22. AS
  23. BEGIN
  24.  
  25. Select CategoryID
  26. From Categories
  27. Where CategoryID = @CategoryID
  28.  
  29. END
  30. GO
  31.  
  32. --3 Create a stored Procedure to update a categories--------------------------
  33.  
  34. CREATE PROCEDURE sp_Categories_Update
  35.  
  36. @CategoryID int,
  37. @CategoryName nvarchar(20)
  38.  
  39. AS
  40. BEGIN
  41.  
  42. Update Categories
  43. Set CategoryName = @CategoryName
  44. Where CategoryID = @CategoryID
  45.  
  46.  
  47. END
  48. GO
  49.  
  50. --4Create a stored Procedure to insert a category---------------------------
  51.  
  52. CREATE PROCEDURE sp_Categories_InsertCategory
  53.  
  54. @CategoryID int,
  55. @CategoryName nvarchar(20)
  56.  
  57. AS
  58. BEGIN
  59.  
  60. Insert into Categories(CategoryID, CategoryName)
  61. Values(@CategoryID, @CategoryName)
  62.  
  63. END
  64. GO
  65.  
  66. --5 Create a stored Procedure to delete a category----------------------
  67.  
  68. CREATE PROCEDURE sp_Categories_DeleteCategory
  69.  
  70. @CategoryID int
  71.  
  72. AS
  73. BEGIN
  74.  
  75. Delete from Categories
  76. Where CategoryID = @CategoryID
  77.  
  78. END
  79. GO
  80.  
  81. --6 Create a stored Procedure to display all categories and their products
  82.  
  83. CREATE PROCEDURE sp_Categories_DisplayCategoryAndProducts
  84.  
  85. AS
  86. BEGIN
  87.  
  88. Select c.CategoryName, products.Products
  89. From Category
  90. Inner join Products on CategoryID
  91.  
  92. END
  93. GO
  94.  
  95. --7 Create a stored Procedure display according given word 'sample'
  96. --if it is sample display top 5 categories
  97. --Else display all
  98. --8 Create a stored Procedure to find employees by their lastname
  99. --if not lastname is specified, return all employees
  100. --9 Create a stored procedure to show all products customers ordered group by productname
  101. --and total of each group of products
  102.  
  103. ---10 --CREATE A SPROC TO FIND THE GENDER OF THE EMPLOYEES
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement