Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- USE [oktell_cc_temp]
- GO
- /****** Object: UserDefinedFunction [dbo].[AddTimeIntervals] Script Date: 28.06.2019 9:42:08 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- -- =============================================
- -- Author: <Author,,Name>
- -- Create date: <Create Date,,>
- -- Description: <Description,,>
- -- =============================================
- ALTER FUNCTION [dbo].[AddTimeIntervals] (@idTask uniqueidentifier, @idOperator uniqueidentifier, @state int, @dateStart datetime, @timeStart datetime, @dateTimeStop datetime) RETURNS
- @returnTable TABLE(IdTask uniqueidentifier, IdOperator uniqueidentifier, [State] int, DateStart datetime, TimeStart datetime, DateTimeStop datetime, Interval nvarchar(20))
- AS
- BEGIN
- DECLARE @Start time
- DECLARE @End time
- SET @Start = @timeStart
- SET @End = CAST(@dateTimeStop as time)
- INSERT INTO @returnTable
- SELECT @idTask
- ,@idOperator
- ,@state
- ,@dateStart
- ,@timeStart
- ,@dateTimeStop
- ,[oktell_cc_temp].[dbo].[Time_Intervals_At_Day].Interval
- FROM [oktell_cc_temp].[dbo].[Time_Intervals_At_Day]
- WHERE (@Start >= TimeStart AND @Start <= TimeEnd)
- OR (@End >= TimeStart AND @End <= TimeEnd)
- OR (TimeStart >= @Start AND TimeEnd <= @End)
- RETURN;
- END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement