/****** program : =========================================******/
USE [OOODB]
GO
/****** Object: UserDefinedFunction [dbo].[fnRTA016_sumOfOvertime01] Script Date: 2022/8/4 上午 11:13:17 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: <Hugo Chang>
-- Create date: <2022-08-03>
-- Description: <get sum of overtime>
-- =============================================
ALTER FUNCTION [dbo].[fnRTA016_sumOfOvertime01]
(
-- Add the parameters for the function here
@p1 int,
@p2 int,
@p3 nvarchar(100)
)
RETURNS integer
AS
BEGIN
-- Declare the return variable here
DECLARE @Result INTEGER = 0;
SELECT @Result=SUM(調整後平日加班時數a) FROM
OPENROWSET(
'MSDASQL',
'DRIVER={SQL Server}; SERVER=localhost; Trusted_Connection=yes',
'EXEC OOODB.[dbo].[RTA016_V5112_MODIFIED5]@ATMY=2021,@ATM=12,@EMPNOA=YC0023,@CTIMEB=NULL,@CTIMEE=NULL,@FavDisplayOpt=optMonth'
);
-- Return the result of the function
RETURN @Result
END
/****** execution : =========================================******/
select [dbo].fnRTA016_sumOfOvertime01(1,1,'')