0

I have SQL script which will generate millions of rows and insert to DB table. How can I execute that script in SSIS in batchwise? Is there any easier solution?

Example:

declare @userinput1 int =1
declare @userinput2 int =10000000;


INSERT INTO table2(col1)
SELECT ones.n + 10*tens.n + 100*hundreds.n + 1000*thousands.n + 10000*laks.n+100000*laks10.n +1000000*crore.n
FROM (VALUES(0),(1),(2),(3),(4),(5),(6),(7),(8),(9)) ones(n),
     (VALUES(0),(1),(2),(3),(4),(5),(6),(7),(8),(9)) tens(n),
     (VALUES(0),(1),(2),(3),(4),(5),(6),(7),(8),(9)) hundreds(n),
     (VALUES(0),(1),(2),(3),(4),(5),(6),(7),(8),(9)) thousands(n),
     (VALUES(0),(1),(2),(3),(4),(5),(6),(7),(8),(9)) laks(n),
     (VALUES(0),(1),(2),(3),(4),(5),(6),(7),(8),(9)) laks10(n),
     (VALUES(0),(1),(2),(3),(4),(5),(6),(7),(8),(9)) crore(n)
WHERE ones.n + 10*tens.n + 100*hundreds.n + 1000*thousands.n + 10000*laks.n +100000* laks10.n +1000000*crore.n  BETWEEN @userinput1 AND @userinput2
ORDER BY 1
13
  • Use a Execute SQL Task? This is very vague here, you need to be more specific on what you're really trying to achieve here. Commented Nov 9, 2018 at 9:55
  • Thanks.is there any option in ExecuteSQLTask run batchwise? Commented Nov 9, 2018 at 10:00
  • @lamu Actually Sql script will generate range of sequence number with other column details and insert to table .. Commented Nov 9, 2018 at 10:03
  • Can you give an example what the sql script you want to execute looks like? Commented Nov 9, 2018 at 10:04
  • actually i want to insert genearted values to table..Sometime i am getting memory exception..so i need to execute this to batchwise Commented Nov 9, 2018 at 10:12

1 Answer 1

1

Use a WHILE loop and only insert a batch at a time, starting from @UserInput1, until you reach @UserInput2.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.