I have a local DTS package that extracts some data from an Oracle database.
I need to have some additional information extracted, but he query to pull it is a monster. Basically I want to pull circuits that meet certain criteria and are not related to a list of orders that meet other criteria.
I have a query that retrieves the list of orders that I want excluded and I use that as a sub-query in the WHERE statement for the circuit retrieval query.
It looks something like:
SELECT circuit_name, related_order
FROM circuits
WHERE circuit_status = 'Active' and related_order not in (SELECT order_no FROM orders WHERE ...)
The sub-query runs and retrieves a list of orders in about 5 minutes. And the main query runs without the sub-query. If I put the two together it takes hours and then fails.
Is it possible to run the sub query on it's own and store the list of orders in a temporary table and then use that table as the source of the IN clause for the query in the transform workflow object?
Is there maybe a better way to accomplish this?
I'm pretty new to SQL Server, so if you could spell out the solution for me, or give me the key words to search for and read about in books online, that would be big help. I've searched, but come up with nothing that seems relavent to what I'm trying to do. _________
Rott Paws
...It's not a bug. It's an undocumented feature!!!
I need to have some additional information extracted, but he query to pull it is a monster. Basically I want to pull circuits that meet certain criteria and are not related to a list of orders that meet other criteria.
I have a query that retrieves the list of orders that I want excluded and I use that as a sub-query in the WHERE statement for the circuit retrieval query.
It looks something like:
SELECT circuit_name, related_order
FROM circuits
WHERE circuit_status = 'Active' and related_order not in (SELECT order_no FROM orders WHERE ...)
The sub-query runs and retrieves a list of orders in about 5 minutes. And the main query runs without the sub-query. If I put the two together it takes hours and then fails.
Is it possible to run the sub query on it's own and store the list of orders in a temporary table and then use that table as the source of the IN clause for the query in the transform workflow object?
Is there maybe a better way to accomplish this?
I'm pretty new to SQL Server, so if you could spell out the solution for me, or give me the key words to search for and read about in books online, that would be big help. I've searched, but come up with nothing that seems relavent to what I'm trying to do. _________
Rott Paws
...It's not a bug. It's an undocumented feature!!!