Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Loop thru Status table and start job

$
0
0

I have a STATUS Tbl, that has a field called CompleteDate.Only if the CompleteDate field has TODAYS Today, then I want to proceed with my ssis task, to insert data in some tables. If the CompleteDate Is not yet todays date, then I want to check the status table again every 10 minutes, until the CompleteDate changes to TODAYS Date. THEN Start my insert process after that.

select

Max(convert(varchar(10), CompleteDate, 121))

from Db.dbo.StatusTable

I used the WAITFOR DELAY But that doesnot help.

Any idea. here is the code I am using BUT THAT Comes out of the LOOP and does not keep rechecking the satus table

declare

@MaxDt  varchar(10)

set @MaxDt=(selectmax(convert(varchar(10), CompleteDate, 121))

from DB.dbo.StatusTable)

--select @MaxDt

DECLARE

@flg BIT

SET

@flg = 0

BEGIN

IFEXISTS(        SELECT

 

CASEWHEN @MaxDt>=convert(varchar(10),getdate(), 121)THEN 1

 

ELSE 0END     

)       

SET @flg= 1

WAITFOR


END

set

DELAY'00:10:00'

Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>