Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- ================================================
- -- Template generated from Template Explorer using:
- -- Create Procedure (New Menu).SQL
- --
- -- Use the Specify Values for Template Parameters
- -- command (Ctrl-Shift-M) to fill in the parameter
- -- values below.
- --
- -- This block of comments will not be included in
- -- the definition of the procedure.
- -- ================================================
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- -- =============================================
- -- Author: <Author,,Name>
- -- Create date: <Create Date,,>
- -- Description: <Description,,>
- -- =============================================
- CREATE PROCEDURE [dbo].[Lab1Zad3]
- -- Add the parameters for the stored procedure here
- @kolumna AS sysname
- AS
- BEGIN
- DECLARE @msg AS NVARCHAR(100)
- -- jezeli nie podano nazwy kolumny
- IF @kolumna iS NULL
- BEGIN
- SET @msg = 'PARAMETR @kolumna NIE MOŻE BYĆ PUSTEJ (NULL)'
- PRINT @msg
- RETURN
- END
- -- czy kolumna nalezy do zbioru
- IF @kolumna NOT IN ('ShipperID', 'CompanyName', 'Phone')
- BEGIN
- SET @msg = 'PARAMETR @kolumna NIE MOŻE BYĆ PUSTEJ (NULL)'
- PRINT @msg
- RETURN
- END
- IF @kolumna = 'ShipperID'
- SELECT ShipperID, CompanyName, Phone FROM Shippers ORDER BY ShipperID
- ELSE IF @kolumna = 'CompanyName'
- SELECT ShipperID, CompanyName, Phone FROM Shippers ORDER BY CompanyName
- ELSE IF @kolumna = 'Phone'
- SELECT ShipperID, CompanyName, Phone FROM Shippers ORDER BY Phone
- END
- GO
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement