Tuesday, December 2, 2014

One Variable for more than one Parameters in ExecuteSQL Task

I have multiple UPDATE statements inside my ExecuteSQL Task. Each one is dependent on one Vairiable e.g. MyId
UPDATE TABLE_A SET COL_A={Something} WHERE ID=?
UPDATE TABLE_B SET COL_B={SomeTHing} WHERE ID=?
This Query takes MyId Variable as Parameter.
Do i need to have as many parameters as my Update Statements are OR there is a way to Have one shared parameter defined inside my ExecuteSQL Task


Answers

Try this:
DECLARE @id int

SELECT @id = ?

UPDATE TABLE_A SET COL_A={Something} WHERE ID=@id
UPDATE TABLE_B SET COL_B={Something} WHERE ID=@id

No comments:

Post a Comment