Advertisement
Guest User

Untitled

a guest
Feb 20th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. -- ================================================
  2. -- Template generated from Template Explorer using:
  3. -- Create Procedure (New Menu).SQL
  4. --
  5. -- Use the Specify Values for Template Parameters
  6. -- command (Ctrl-Shift-M) to fill in the parameter
  7. -- values below.
  8. --
  9. -- This block of comments will not be included in
  10. -- the definition of the procedure.
  11. -- ================================================
  12. SET ANSI_NULLS ON
  13. GO
  14. SET QUOTED_IDENTIFIER ON
  15. GO
  16. -- =============================================
  17. -- Author: <Author,,Name>
  18. -- Create date: <Create Date,,>
  19. -- Description: <Description,,>
  20. -- =============================================
  21. CREATE PROCEDURE [dbo].[Lab1Zad3]
  22. -- Add the parameters for the stored procedure here
  23. @kolumna AS sysname
  24. AS
  25. BEGIN
  26.  
  27. DECLARE @msg AS NVARCHAR(100)
  28.  
  29. -- jezeli nie podano nazwy kolumny
  30. IF @kolumna iS NULL
  31. BEGIN
  32. SET @msg = 'PARAMETR @kolumna NIE MOŻE BYĆ PUSTEJ (NULL)'
  33. PRINT @msg
  34. RETURN
  35. END
  36.  
  37. -- czy kolumna nalezy do zbioru
  38. IF @kolumna NOT IN ('ShipperID', 'CompanyName', 'Phone')
  39. BEGIN
  40. SET @msg = 'PARAMETR @kolumna NIE MOŻE BYĆ PUSTEJ (NULL)'
  41. PRINT @msg
  42. RETURN
  43. END
  44.  
  45. IF @kolumna = 'ShipperID'
  46. SELECT ShipperID, CompanyName, Phone FROM Shippers ORDER BY ShipperID
  47. ELSE IF @kolumna = 'CompanyName'
  48. SELECT ShipperID, CompanyName, Phone FROM Shippers ORDER BY CompanyName
  49. ELSE IF @kolumna = 'Phone'
  50. SELECT ShipperID, CompanyName, Phone FROM Shippers ORDER BY Phone
  51. END
  52. GO
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement