title: How do I assign numeric value of an SQL query result to a package variable of data type Double?
body: <p>I have what should be a simple task - Populate a user variable using the ResultSet from an Execute SQL task</p>
  
  <pre><code>SELECT MainID FROM TableA WHERE TableA_ID = 1` 
  </code></pre>
  
  <p>(This will only return one Column and one Row).</p>
  
  <p>MainID is currently stored as a user-defined datatype in the database.  The value is stored in the format XXXX.Y (e.g. 8008.1).</p>
  
  <p>If I change the UserVariable to a String datatype, I can assign the value without any problems either CASTing or CONVERTing the ResultSet to STRING/NUMERIC/FLOAT.</p>
  
  <pre><code>SELECT CAST(MainID as NUMERIC(9,1)) as 'MainID' FROM TableA WHERE TableA_ID = 1;
  SELECT CAST(MainID as FLOAT) as 'MainID' FROM TableA WHERE TableA_ID = 1;
  SELECT CAST(MainID as VARCHAR(10)) as 'MainID' FROM TableA WHERE TableA_ID = 1;
  </code></pre>
  
  <p>or</p>
  
  <pre><code>SELECT CONVERT(NUMERIC(9,1), MainID) as 'MainID' FROM TableA WHERE TableA_ID = 1;
  SELECT CONVERT(FLOAT, MainID) as 'MainID' FROM TableA WHERE TableA_ID = 1;
  SELECT CONVERT(VARCHAR(10), MainID) as 'MainID' FROM TableA WHERE TableA_ID = 1;
  </code></pre>
  
  <p>However, I can't assign the value if the User Variable Datatype is DOUBLE.  I get the following error message:</p>
  
  <blockquote>
    <p>[Execute SQL Task] Error: An error occurred while assigning a value to
    variable "dUserVariable": "The type of the value being assigned to
    variable "User::dUserVariable" differs from the current variable type.
    Variables may not change type during execution. Variable types are
    strict, except for variables of type Object. ".</p>
  </blockquote>
  
  <p>I'm fairly new to SSIS so I'm a bit stumped on how to get this conversion to go through.</p>
  
  <p>Any ideas?</p>