Link to home
Start Free TrialLog in
Avatar of Becky Edwards
Becky EdwardsFlag for United States of America

asked on

Need to run extract weekly on Tuesday

I need to build into a SQL query that this extract will run every Tuesday.  I was thinking I could use the date_dimension table that has Day_of_WEek column = Tuesday, or Day_of_Week_Index = 2.  But that is all I have.  Can someone help with this?

Right now my query is set up like this:
declare @yearmonth varchar(15) = '201709'

date_dimension ar_date
INNER JOIN hsp_bkt_snapshot bkt_snap on bkt_snap.snap_start_date <= ar_date.calendar_dt and bkt_snap.snap_end_date >= ar_date.calendar_dt
INNER JOIN hsp_har_snapshot har_snap on bkt_snap.HSP_ACCOUNT_ID = har_snap.HSP_ACCOUNT_ID AND har_snap.snap_start_date <= ar_date.CALENDAR_DT and har_snap.SNAP_END_DATE >= ar_date.CALENDAR_DT
Avatar of Brian Crowe
Brian Crowe
Flag of United States of America image

I'm a little confused as to what you are asking for and the code provided is incomplete.  Are you looking for a task to run every tuesday or a query that pulls data for tuesdays or something else entirely?
ASKER CERTIFIED SOLUTION
Avatar of Vitor Montalvão
Vitor Montalvão
Flag of Switzerland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Agree with comments made by both Brian and Vitor.

And you would also need to add in after the joins, in addition to any other conditions...

WHERE ar_date.Day_of_Week_Index = 2

Open in new window

Avatar of Becky Edwards

ASKER

Thank you!  This will work perfect.