次のコード(一部) を含むスカラー値関数を作成しました。
declare @start_time22 time(7);
select @start_time22=Courses.[Course start time] from Courses where [Course ID]=@val1 and [Course days]='monday wednesday';
if(@start_time22 is not null)
begin
IF (@start_time not between @start_time22 and @end_time22)
BEGIN
SET @Result = 1
END
ELSE
BEGIN
SET @Result = 0
END
IF (@end_time not between @start_time22 and @end_time22)
BEGIN
SET @Result = 1
END
ELSE
BEGIN
SET @Result = 0
END
end
else
begin
set @Result = 5
end
RETURN @Result
関数は常に値 " 5 " を返すので、そもそも型時間を比較できるかどうか疑問に思っていました... それとも私のコードに何か問題がありますか?