title: SSIS - OLEDB Source - how to use sql query with variables?
body: <p>I have this query that I want to export its contents to a table:</p>
  
  <pre><code>DECLARE @bdname VARCHAR(50)
  SET @bdname = ?
  
  SELECT 
      @bdname, 
      CONVERT(CHAR(30), dp2.name), 
      CONVERT(CHAR(20), dp.name) 
  FROM  
      sys.database_principals AS dp 
  INNER JOIN
      sys.database_role_members AS drm ON dp.principal_id = drm.role_principal_id 
  INNER JOIN
      sys.database_principals AS dp2 ON drm.member_principal_id = dp2.principal_id
  WHERE  
      (dp2.principal_id &gt; 4) AND (dp2.type &lt;&gt; 'R')
  </code></pre>
  
  <p>If I put this as part of a Execute SQL Task, it goes ok, but I can't (don't know how) then map the results into something that I can export to a SQL table.</p>
  
  <p>Can anyone guide me on how can I put the results of this query into a table? It's because if I use dataflow and ole db source, it does not accept this type of query.</p>
  
  <p>Any help would be much appreciated.</p>
  
  <p>Thanks</p>