Skip to content Skip to sidebar Skip to footer

Parameter Mapping Using An Execute Sql Task

I am trying to create a temporary table and insert data into the temp table within an Execute SQL Task inside a foreach loop container. Here are the sql tasks IF OBJECT_ID('TEMPDB.

Solution 1:

Just go to Expressions Tab as shown in the screenshot you provided and write the following expression to SqlStatmentSource property

"IF OBJECT_ID('TEMPDB.DBO.#TEMP') IS NOT NULL
DROP TABLE #TEMP
GO

CREATE TABLE #TEMP 
      ( ... );

INSERT INTO #TEMP
      SELECT (...)
  FROM table t1 INNER JOIN table2 t2
  ON t1.id = t2.table1_id
WHERE t1.value = '"  +  @[User::Where_Variable]  +   "'"

enter image description here

Solution 2:

Populate a variable with your entire SQL script, and use the variable as your SQLSourceType in your Execute SQL Task.

Post a Comment for "Parameter Mapping Using An Execute Sql Task"