Using CTE or subqueries with derived tables in a single SQL query and running it through Execute SQL Task in SSIS could be an option.
SQL Queries
In SSIS I need to run two queries, so that the output from the first will become input into the second query. The first query I have uses an OLE DB Source and creates output with several records. I would like to use the output from the first query as input into a second query to further filter and aggregate the records. I would like to do this without using a stored procedure. I have read about using result sets to pass to stored procedures, but there should be a more straight forward way of doing this. I have also tried saving the results of the first sql query into a temporary table and then using the temp table as input into the second query, but I get errors doing that in OLE DB Source. Can you please provide me with a simple way of doing this? An example would be most appreciated.
2 answers
Sort by: Most helpful
-
-
ZoeHui-MSFT 36,116 Reputation points
2021-06-14T05:44:48.997+00:00 Hi @Gary August ,
As @Praveen Babu Vejandla said, CTE is a good way to resolve the issue.
More details you may refer:
with-common-table-expression-transact-sql
Regards,
Zoe
If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
Hot issues October