SSIS OLE使用DBCommand调用tsql函数

发布于 2024-09-15 00:08:23 字数 796 浏览 1 评论 0原文

我正在将 Oracle 数据导入 SQL Server。在我的 OLE DB 源运行查询以获取要处理的数据之后,我尝试以某种方式对字段值调用 TSQL 函数...

我有一个 SSIS 数据流,其中有一个名为 DepartureDateGMT 的日期时间列和一个名为 DepartureTimeZoneKey 的整数列。

我有一个名为 dbo.udf_ConvertFromGMT(,) 的 TSQL 函数,它返回一个日期时间

的调用值:

dbo.udf_ConvertFromGMT(DepartureDateGMT,DepartureTimezoneKey)

我正在尝试创建一个 OLE DB 命令,该命令填充名为 DepartureDate 的列,该列保存每行 在 SSIS 数据流中。

我没有更新/插入到现有表中,我只是尝试将结果存储到数据流数据集每行的 DepartureDate 列中

我已经尝试了很多东西,例如

Exec ? dbo.udf_ConvertFromGMT(?,?)

选择 dbo.udf_ConvertFromGMT(DepartureDateGMT,DepartureTimezoneKey)

dbo.udf_ConvertFromGMT(?,?)

声明 @Result DATETIME SET @Result = dbo.udf_ConvertFromGMT(?,?)

但我收到:语法错误、权限违规或其他非特定错误

我是不是找错了树?我尝试过使用 DerivedColumn,但它不允许调用 TSQL 函数。

谢谢!

I'm importing Oracle data into SQL Server. After my OLE DB Source that runs a query to grab the data to process, I'm trying to call a TSQL function on a field value somehow...

I have an SSIS data flow where I have a datetime column called DepartureDateGMT, and an integer column called DepartureTimeZoneKey.

I have a TSQL Function called dbo.udf_ConvertFromGMT(,) that returns a datetime

I am trying to create an OLE DB Command that fills a column called DepartureDate that holds the value of the call:

dbo.udf_ConvertFromGMT(DepartureDateGMT,DepartureTimezoneKey)

for each row in the SSIS dataflow.

I'm not updating/inserting into an existing table, I'm just trying to store the result into the DepartureDate column of each row of the data flow's dataset

I have tried alot of things, like

Exec ? dbo.udf_ConvertFromGMT(?,?)

SELECT dbo.udf_ConvertFromGMT(DepartureDateGMT,DepartureTimezoneKey)

dbo.udf_ConvertFromGMT(?,?)

DECLARE @Result DATETIME
SET @Result = dbo.udf_ConvertFromGMT(?,?)

But I'm getting :Syntax Error, permission violation or other nonspecific error

Am I barking up the wrong tree? I have tried using DerivedColumn, but it doesnt allow calling a TSQL function.

Thanks!

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

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

发布评论

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

评论(1

汹涌人海 2024-09-22 00:08:23

数据流任务中的 OLE DB 命令旨在为数据流中的每一行运行一次 SQL 语句。无论它是否适合您,如果有很多行需要处理,您可能会对性能不满意。您是否研究过 SSIS 表达式语言,看看是否可以将功能(而不是函数调用)移动到派生列组件中?

如果必须使用 OLE DB 命令,您可以尝试将 SQL 函数更改为 SQL 存储过程。在 OLE DB 命令中,您可以调用这样的过程,

EXEC dbo.usp_ConvertFromGMT ?, ?, ? OUTPUT

我认为您可以将结果作为输出参数(命令中的第三个?)映射到数据流列。

The OLE DB Command in a Data Flow task is designed to run a SQL statement once for each row in the data flow. Whether it works for you or not, you may not be happy with the performance if there are many rows to process. Have you looked into the SSIS expression language to see if you can move the functionality, instead of the function call, into a Derived Column component?

If you must use the OLE DB Command, you might try changing your SQL function to a SQL stored procedure. In the OLE DB Command you can call a procedure like this

EXEC dbo.usp_ConvertFromGMT ?, ?, ? OUTPUT

I think you can then map your result as the output parameter (3rd ? in the command) to a data flow column.

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