나는 그들이 보인다 귀하의 요구 사항에 대한 불분명 해요 약간 impracticle. 그러나 여기에 내 갈망이있다.
DECLARE @A AS TABLE(
_start_day_of_week int,
_start_hour int,
_start_minute int,
_end_day_of_week int,
_end_hour int,
_end_minute int,
_title varchar(10),
_id int
)
--Above is temp table for example
INSERT @A
SELECT 5,15,30,6,2,30,'SAMPLE 1', 1 UNION ALL
SELECT 6,15,30,6,17,30,'SAMPLE 2', 2
DECLARE @month int = datepart(month,getdate())
DECLARE @currentDay int = datepart(dw,getdate())
DECLARE @currentHour int = datepart(hour, getdate())
DECLARE @currentMinute int = datepart(minute, getdate())
SELECT * FROM @A --Don't use select *. This is just an example.
WHERE --Where GETDATE matches
_start_day_of_week = @currentDay --The day of week
AND
_start_hour = @currentHour --and time of those rows
AND
_start_minute = @currentMinute
--I have not done any matching against the _end columns as
--your criteria are vague. Should it exclude all days except
--the current day and the currentday+1?
-- But you would use a similar method.
테이블 DDL, 일부 샘플 데이터 및 예상 결과를 게시 할 수 있습니까? 귀사의 요구 사항을 이해하는 데 도움이됩니다. –
물론, 테이블 구조에 대해 좀 더 자세히 설명했습니다. @Robert Kaucher @Victor – Corgalore