有没有办法在 SSIS 的数据流中执行 T-SQL 代码?
背景
我有一个维度表,每天都有一条记录。 每条记录都有一个主键,因此示例数据如下:
Dimension Table --------------- --------------------------------- | ID | DateTime | --------------------------------- | 1083 | 04/10/2008 10:02:00 PM | ---------------------------------
我想做的是获取具有 SQL 日期时间值的源数据列(例如 04/10/2008 10:02:00 PM) >) 并让 SSIS 从维度表中导出主键应该是什么(上面示例中的1083
)。 我试图将其放入我的包中的数据流中,并避免使用临时表。
我想在数据流期间调用数据库函数,让我的 SSIS 包发现 datetime
记录的 timeid
。 我尝试过使用 DeriveColumn,但这似乎不允许使用 T-SQL; 而只是内置于 ANSI SQL 中的函数。
问题
还有另一种方法可以在数据流中执行此操作吗? 或者我是否需要使用临时表并使用数据流外部的 SQLTask
来操作我的数据?
Background
I have a dimension table that has a single record for each day. Each record has a primary key so example data would be:
Dimension Table --------------- --------------------------------- | ID | DateTime | --------------------------------- | 1083 | 04/10/2008 10:02:00 PM | ---------------------------------
What I am trying to do is take my source data column which has a SQL datetime value (such as 04/10/2008 10:02:00 PM
) and have SSIS derive what the primary key from the dimension table should be (1083
in the above example). I am trying to fit this into the Data Flow within my package and avoid using staging tables.
I would like to call a database function during my dataflow to have my SSIS package discover the timeid
for a datetime
record. I have tried to use DeriveColumn
but that doesn't seem to allow the use of T-SQL; rather only functions that are built into ANSI SQL.
Question
Is there another way to do this inside the dataflow? Or will I need to use staging tables and use a SQLTask
outside of the dataflow to manipulate my data?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果我理解你的话,你有一个具有时间维度的数据集市,你需要获取与特定时间对应的timeId。
如果这是正确的,那么您想要使用 Lookup 组件。 对于参考表,请使用诸如 SELECT timeId, timeStamp FROM TimeDimension 之类的内容,然后查找保存时间戳的输入列。 使用 timeId 作为输出列,现在数据流中的每一行都将具有与其时间戳对应的 timeId。
If I understand you, you have a data mart with a time dimension, and you need to get the timeId that corresponds to a particular time.
If that's correct, then you want to use a Lookup component. For the reference table use something like
SELECT timeId, timeStamp FROM TimeDimension
, then look up against the input column that holds the timestamp. Use the timeId as the output column, and now each row in your data flow will have the timeId that corresponds to its time stamp.