Code Reference A collection of code for my reference (and perhaps other people too)

12Feb/100

Temporary tables in SSIS

On one of our projects, we had some SQL that contained a temp table. This temp table is not one that will be used across several Data Flow Tasks. It is only used within a single one.

I don't want to hear the arguments for not using temp tables. Sometimes you just have to. We found ourselves with one of those situations.

After a lot of research and reading of other people's blog posts, I found a solution.

We had been using an OLE DB connection to our database.
Inside our Data Flow Task we placed our SQL inside an OLE DB Source.
None of the suggested solutions I read thru allowed me to use a temp table.

Our solution....

Use an ADO DB connection. Then an ADO NET Source.
Then under the properties of the ADO DB connection, we set
- RetainSameConnection = True
- DelayValidation = True
Most important, we didn't use a temporary table (CREATE TABLE #Res .....). We used a variable table (DECLARE @Res TABLE .....) instead.

That did the trick.

I am glad this worked because I really didn't want to deal with Global tables or defining a global table in the DB ahead of time or any workarounds like that. This was simple and it worked.

For some reason, this won't work with an OLE DB connection. We think we know why, but have not found the documentation it.

Tagged as: , Leave a comment
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment


No trackbacks yet.