title: SSIS variable of object type to string conversion
body: <p>I am using SQL Server 2014 and for SSIS designer SSDT BI with Sisual studio 2013. I have the following query in an Execute SQL Task with Single resultset assigning the value to variable "role" of string data type.</p>
  
  <pre><code>SELECT DISTINCT (STUFF((SELECT CAST(',' + SubTableUser.UserRole AS VARCHAR(MAX))
          FROM TableUser AS SubTableUser
          WHERE SubTableUser.UserID = TableUser.UserID
          FOR XML PATH('')), 1, 1, '')) AS UserRole
  FROM TableUser
  </code></pre>
  
  <p><strong><em>Execute SQL Task Error:</em></strong> </p>
  
  <p>The value type (__ComObject) can only be converted to variables of type Object.
  An error occurred while assigning a value to variable "role": "The type of the value (DBNull) being assigned to variable 
  "User::role" differs from the current variable type (String). Variables may not change type during execution. 
  Variable types are strict, except for variables of type Object.".</p>
  
  <p>I tried to assign the object variable value to a string variable in a script task <code>String.Format("{0}", Dts.Variables["User::role"])</code>  and get this value "<strong><em>System.__ComObject</em></strong>" instead of the actual value.</p>