STORED PROCEDURE
Parametresiz Procedure
CREATE PROC SelectAllCustomers
AS
SELECT * FROM Customers
GO;
.
.
.
.
EXEC SelectAllCustomers;
Parametreli Str. Procedure
CREATE PROC SelectAllCustomers
(
@City nvarchar(30)
)
AS
SELECT * FROM Customers WHERE City = @City
GO;
.
.
.
.
EXEC SelectAllCustomers City='Berlin'
ÖRNEK:
create PROCEDURE sp_CustSatisToplamBwDates
(
@DateBegin datetime
@DateEnd datetime
)
AS
SELECT SUM(SD.BirimFiyati*SD.Miktar) AS TOTALSATIS FROM Personeller P
INNER JOIN Satislar S ON S.PersonelID=P.PersonelID
INNER JOIN [Satis Detaylari] SD ON SD.SatisID= S.SatisID
WHERE S.SatisTarihi>=@DateBegin and s.SatisTarihi<=@DateEnd
GO
ÇAĞIRILIŞI:
exec CustSatisToplamBwDates @DateBegin='1989-01-01',@DateEnd='2000-01-01'