title: How do I change the package variable value during runtime?
body: <p>I'm running an SSIS package and I want to set the value of a desired variable during runtime. Here an example</p>
  
  <p><code>variable1= 1145554478 nvarchar(30)</code> </p>
  
  <p>I'm using nvarchar since I'm adding more characters to the string.</p>
  
  <pre><code>variable2= [ + variable1 + _S] 
  </code></pre>
  
  <p><code>variable1</code> and <code>variable2</code> are package variables.</p>
  
  <p>I've searched for ways to set a value to the variables during runtime. As I thought, it seems that it could be done with an SQL Task Editor. So, I created one. Set the <code>variable1</code> as imput value, and <code>ResultSet</code> to single row, and set it to variable2.</p>
  
  <p>then in the code I wrote</p>
  
  <pre><code>set Variable2 = '[' + ? + '_S]'
  </code></pre>
  
  <p>It's not working, here's the error</p>
  
  <blockquote>
    <p>Error: 0xC002F210 at Execute SQL Task, Execute SQL Task: Executing the
    query "set Variable2 = '[' + ? + '_S]'" failed with the following
    error: "Line 1: Incorrect syntax near '='.". Possible failure reasons:
    Problems with the query, "ResultSet" property not set correctly,
    parameters not set correctly, or connection not established correctly.
    Task failed: Execute SQL Task.</p>
  </blockquote>
  
  <p>Is a SQL Task editor the best way of setting a variable during runtime?</p>
  
  <p>I think the code I wrote in the Task editor is wrong, since the code in there is not always the same ordinary SQL used regularly.</p>