在 SSIS 包中使用临时表

发布于 2024-11-30 01:24:22 字数 527 浏览 0 评论 0原文

我正在编写从一个数据库到另一个数据库的基本文件转储。我正在使用 SSIS 2008 并创建几个包来将我的数据从 MSSQL 2010 数据库转换为 MYSQL 5.1 数据库。

所有连接均已设置,记录可以在两个数据库之间传输,但我想在转换过程中使用临时表,并使用临时表作为数据流任务中的 MSSQL 源,以将表转储到等待的 MYSQL 表中。

我在设置此问题时遇到了问题。我正在使用 OLEDB 连接,并将 RetainSameConnection 属性和 DelayValidation 属性设置为 true。将源图设置为 MSSQL 数据库的源时,我无法从控制流中找到在早期任务中创建的临时表。我对这两项任务使用相同的连接管理器。

有人对此有什么想法或经验吗?

作为一个简单的例子,一个任务确实......

SELECT * 
INTO #TMP
FROM CUSTOMERS

(这是一个简化的例子,我意识到在这种情况下我可以只使用客户表,所以请耐心等待) 是否可以在数据流操作中使用此临时表作为源表?

I am writing a basic file dump from one database to another. I am using SSIS 2008 and creating several packages to transform the data I have from a MSSQL 2010 database to a MYSQL 5.1 database.

All the connections are set up and records can be tranfered between the two databases but I would like to use temp tables in the transform processes and use the temp table as the MSSQL source in a dataflow task to dump the table in an awaiting MYSQL table.

I have been having problems setting this up. I am using an OLEDB connection and have set the RetainSameConnection property as well as the DelayValidation property to true. When setting up the source figure as the source from the MSSQL database I cannot find the temp table I have created in an earlier task from the control flow. I am using the same connection manager for these two tasks.

Anyone have any ideas or experience with this?

As a simple example one task does..

SELECT * 
INTO #TMP
FROM CUSTOMERS

(This is a simplified example and I relize in this case I could just use the Customers table so bear with me)
Is it possible to use this temp table in a dataflow operation as the source table?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

陌路黄昏 2024-12-07 01:24:22

正如我在评论中提到的,这不是解决方案,而是解决方法。 SSIS 使用结果集的形状来绑定任务中的属性。由于临时表在数据库中并不总是可用,即使您将 DelayValidation 设置为 true,这也可能会在 SSIS 中导致错误。

我的解决方案是在您要连接的任何数据库中创建一个 SSIS 架构。这样做的原因是安全性以及仅在 SSIS 包中使用的对象(主要是临时表)的明确分离。

与其将表扔到您的 dbo 架构中(无论如何您都不应该这样做,真丢脸),您可以在 SSIS 架构中创建它们。典型的数据流会在开始时截断表、加载值并执行所需的任何操作,并可选择在完成时截断它。只要表始终可用,SSIS 就可以检查结果集的形状。

As I mentioned in my comment, not much of a solution and more of a workaround. SSIS uses the shape of result sets to bind properties in tasks. As temp tables are not always available in the database this can cause errors in SSIS even if you set DelayValidation to true.

My solution is to create an SSIS schema in whichever database you're connecting to. The reasons for doing so are security and clear separation of objects that are only used within SSIS packages - primarily staging tables.

Instead of throwing tables in your dbo schema (you shouldn't be anyway, shame on you) you'd create them in the SSIS schema. A typical data flow would truncate the table when it begins, load values and perform whatever operations are required, optionally truncating it when complete. As long as the table is always available SSIS can examine the shape of result sets.

江挽川 2024-12-07 01:24:22

您不应使用临时表作为源,因为它无法识别选择的列。请改用表变量或 CTE。

You should not use temp tables as the source as it will not recognize the columns for the select. use table variables or CTEs instead.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文