mesutd0nmez
10/25/2016 - 2:07 PM

Create Function Example

Create Function Example

-- ================================================
-- Template generated from Template Explorer using:
-- Create Scalar Function (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 function.
-- ================================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date, ,>
-- Description:	<Description, ,>
-- =============================================
CREATE FUNCTION GetRequestDeliveredDate
(
@RequestId int 
	
)
RETURNS datetime
AS
BEGIN
	
	declare @DeliveredDate datetime

	SELECT @DeliveredDate=min(LogDate) FROM [dbo].[RequestLog](NOlock)
WHERE RequestId=@RequestId and IsDelivered=1

	RETURN @DeliveredDate

END
GO