0

EDIT:

I do not believe the Using temporary tables in ssis package question helps me. I can't use a stored procedure because I don't have write permissions in DatabaseA. I am toying around with even simpler code such as:

CREATE TABLE #A ( ID INT

)

INSERT INTO #A SELECT ID FROM B

select * from #A

which still gives me the metadata error. Not sure what to do


I understand this question has been asked in several varieties here, the issue is that I am not expert enough to really understand if the answers apply to my situation or not. I am decent at the SQL code, but the SSIS part is not in my wheelhouse.

High-level overview. I have data in DatabaseA. I have no write permissions in DatabaseA. There is a major issue in DatabaseA with regards to my data. There is no static unique identifier for the items I am analyzing. To do the calculations I need, I first need to do some backing-into reference data to make my own unique identifier and then perform the calculations I need. The code I have, using temp tables, and storing all final results in a temp table, can be performed in DatabaseA.

The issue is that I can't use that code in SSIS, because I get a metadata error since I use temp tables. I have tried to use CTEs, but my code in SSIS ran for 24 hrs and was still running. Using temp tables in DatabaseA gave me my results in 2.5 hrs.

Although we have our own database, DatabaseB, I can't bring in the intermediate steps there. I can't perform the calculations in DatabaseB, I have tried. Basically we don't have enough space for the calculations, though we have enough memory to store the tables. My IT team is not a help, they are inundated with other things so I need to figure this one out. If I could get the code to run as-is in DatabaseA and just have the results pulled into DatabaseB it would be fine. This is what I am trying to do with the SSIS packages. My code is something like the following where the temp tables are created to materialize smaller resultant tables.

Is there any hope for me here to get this to work in SSIS? The code works in a reasonable time if I just run it in DatabaseA and store the results in a temp table. I just need to get the over to DatabaseB

Select
*
into #A
from A where abc

Select
*
into #B
from B where dce


Select
*
into #C
from C where fgh

select
...
into #D
from #C join #A on...join (#C) #B on where ijk...

Select
...

from #D join E on... where xyz

There are more intermediate steps, but not many. But if I could get an idea of a general solution here, I think I should be able to apply it to my code. Any help is appreciated.

4
  • 2
    Does this answer your question? Using temporary tables in ssis package Commented May 31 at 6:04
  • This question is similar to: Using temporary tables in ssis package. If you believe it’s different, please edit the question, make it clear how it’s different and/or how the answers on that question are not helpful for your problem. Commented Jun 1 at 17:44
  • The link didn't exactly help. I am probably missing something. I explicitly did a create table statement for each temp table, specifying the columns and data types. But I still get the same error. I'm not using a stored procedure so I'm not sure if the other question helps. I can't use a stored procedure because I don't have write permissions in DatabaseA. As a note the solution to that question provides a link that doesn't work. Commented Jun 2 at 16:34
  • I stumbled onto this which is promising. youtube.com/watch?v=INgsOSJefdM. It has worked for some simpler test cases and am working on seeing if I can get this to work for my full query. Basically the idea is to first create a global temp table in the source server, dump the results into the global temp table, and use a data flow task to pull from the global temp table and bring it in to the destination. However, you need to set your settings for DelayDataValidation to true AND RetainSameConnection to true. Commented Jun 2 at 19:33

1 Answer 1

0

After digging a bit more, I found this video youtube.com/watch?v=INgsOSJefdM. It has worked for me. I'm not sure if it will poses any issues running it on a monthly basis, but it worked for my current pull. Basically the idea is to first create a global temp table in the source server, dump the results into the global temp table, and use a data flow task to pull from the global temp table and bring it in to the destination. However, you need to set your settings for DelayDataValidation to true AND RetainSameConnection to true.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.