0

Using an SSIS package, is it possible to load sql code that contains variables in it, replace those variables and run the code without saving it(similarly to DTS 2000 packages)?

For example, I want to run Code.sql, which contains the following:

SELECT *
INTO XXDBXX.dbo.Table2    
FROM XXREADDBXX.dbo.Table1

I was planning on creating a script to replace the "XX" strings with variables I set up using SSIS.

So, here are the steps I want to do:

  1. Run script to replace sql file variables.
  2. Run SQL code
  3. SQL code finishes running, and code still retains its variables.

Please let me know if anything needs clarification.

2 Answers 2

1

create a variable in SSIS @SQL (User::SQL)

Script task to load template sql from file & replace variables with required values. Use C# String.Replace();

Execute task to use @SQL (SQLSourceType = Variable)

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

Comments

0

Create a variable in SSIS

https://www.red-gate.com/simple-talk/sql/ssis/ssis-basics-introducing-variables/

You can also run SQL code and then replace parameters such as:

EXEC PROC XXDBX ?,?

The question marks being your parameter or variable created above.

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.