Saobi
Saobi

Reputation: 17021

Dynamic query in SSIS Package

I have an OLE DB Command component in an SSIS Package that runs an update statement against a SQL table. Now, my statement initially is like:

update myTable set columnA=?, columnB=? where columnC=?

Where the three "?"'s are inputs to my component from another Conditional Split component. I can link each column name with each input parameter (the ?), so column A = param0, column B = param1.

Now, my query is more complex, I need to do;

update myTable set columnA=(param1+param2), columnB=(param2) where columnC=param1*param2

How can I do this in SSIS?

Upvotes: 0

Views: 1550

Answers (2)

Jefe
Jefe

Reputation: 598

Why not just have a derived column before the update command, and calculate these fields?

Create new columns with names/value as such:
columnA=param1+param2:
columnB=param2:
columnC=param1*param2:

Then redirect the output to the update command and use them as the parameters. This way, you do not have to do any calculations in your query, which makes for a much cleaner IS package.

Upvotes: 2

John Saunders
John Saunders

Reputation: 161773

Yes. Simply compute those values in a Derived Column transform, and use them instead of the parameters you're using now.

Upvotes: 1

Related Questions