question

yosafatsaragih-1755 avatar image
0 Votes"
yosafatsaragih-1755 asked Monalv-msft edited

Reccurent SSIS SQL Task with for loop

I want to loop through date said 2000-01-01 to 2000-12-31 and i put the date as variable (said start and stop). I want to recursively call insert query which structured like this:

FOR date in range (start,stop):
INSERT INTO TABLE A (SELECT ...)
ON CONFLICT (CONSTRAINT)
DO UPDATE (...)
WHEN
DATE + INTERVAL 1 DAY

I wonder if i can use SSIS Loop container and loop through day using this.

sql-server-integration-services
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

Monalv-msft avatar image
0 Votes"
Monalv-msft answered Monalv-msft edited

Hi @yosafatsaragih-1755 ,

We can store date and sql query in variables.

Then we can use variable in For Loop and set SQLSourceType as Variable in Execute SQL Task.

Please refer to the following links and pictures:
1.SSIS For Loop Container with Date Variable
2.Parameter SQL Insert into Statement SSIS Package

72963-cf.png
72917-forloop.png
72918-est.png
72919-expressionbuilder.png

Best regards,
Mona


If the answer is helpful, please click "Accept Answer" and upvote it.

Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.




cf.png (30.2 KiB)
forloop.png (16.0 KiB)
est.png (24.4 KiB)
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @yosafatsaragih-1755 ,

May I know if you have anything to update?

Best regards,

Mona

0 Votes 0 ·