Skip to content
Loading
  • Sachin Singh
    +1

    create a job

    1. Put your query into stored procedure,

    2. Create a job that will check the date and time and launch the SP

    3. Set interval for Job

    +1
  • Rijwan Ansari
    +1
    You can create Stored Procedures with Parameters Currentdate and duration to get data with secific time intervals.
     
    Example:
     
    1. CREATE PROCEDURE SPQueryName   
    2. @CurrentDate datetime ,  
    3. @Duration int  
    4.   
    5. AS  
    6. SELECT * FROM TableName WHERE CreatedOnUtc > @CurrentDate and CreatedOnUtc < DATEADD(minute,@Duration,@CurrentDate)  
    7. GO;  
    DATEADD is used for date + duration
     
    1. DATEADD(minute,@increase,@InputDate)  
    And you can execute query with current and duration. Additionally you can use SYSDATETIME() for system current datetime.
     
    Regards
    Rijwan 
    +1
  • Asma Khalid
    +1
    You can create a store procedure as follow i.e.
    1. CREATE PROCEDURE [dbo].[sp_get_schedule_data]  
    2.   
    3. AS  
    4. BEGIN  
    5.     DECLARE @startTime nvarchar(max)  
    6.     DECLARE @endTime nvarchar(max)  
    7.   
    8.     SET @startTime = GETDATE()  
    9.     SET @endTime = DATEADD(MINUTE, 150, @startTime)  
    10.   
    11.   
    12.     SELECT *   
    13.     FROM MyTable  
    14.     WHERE MyTable.CreatedDatetime >= @startTime  
    15.     AND MyTable.CreatedDatetime <= @endTime  
    16. END 
    Create windows service of particular schedule and call this procedure to get/send data accordingly.
    +1