version 1:
CREATE PROC [dbo].[usp_WDelay]
@id int,
@tme int
AS
SELECT *
FROM dbo.tblWebToursPrices
WHERE SupServID = @id AND EndDate >= (GETDATE() - isnull(@tme, getdate()))
ORDER BY EndDate ASC
GO
version 2:
CREATE PROC [dbo].[usp_WDelay]
@id int,
@tme int = 0
AS
if @tme <> 0
SELECT *
FROM dbo.tblWebToursPrices
WHERE SupServID = @id AND EndDate >= (GETDATE() - @tme)
ORDER BY EndDate ASC
else
SELECT *
FROM dbo.tblWebToursPrices
WHERE SupServID = @id
GO
|