如何在DTS数据转换任务中使用存储过程?
我有一个包含数据转换任务(数据泵)的 DTS 包。 我想使用带有参数的存储过程的结果来获取数据,但 DTS 不会预览结果集,也无法定义数据转换任务中的列。
有人让它发挥作用吗?
警告:存储过程使用两个临时表(当然,并清理它们)
I have a DTS package with a data transformation task (data pump). I’d like to source the data with the results of a stored procedure that takes parameters, but DTS won’t preview the result set and can’t define the columns in the data transformation task.
Has anyone gotten this to work?
Caveat: The stored procedure uses two temp tables (and cleans them up, of course)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您需要将它们实际加载到表中,然后如果必须进行转换,则可以使用 SQL 任务将其从该表移动到永久位置。
但是,我发现,如果使用存储过程来获取数据,那么同时将其移动到目的地几乎同样快速且容易!
You would need to actually load them into a table, then you can use a SQL task to move it from that table into the perm location if you must make a translation.
however, I have found that if working with a stored procedure to source the data, it is almost just as fast and easy to move it to its destination at the same time!
不,我只能使用 DTS 存储过程,让它们将状态保存在废品表中。
Nope, I could only stored procedures with DTS by having them save the state in scrap tables.
为存储过程参数输入一些有效值,以便它运行并返回一些数据(甚至没有数据,您只需要列)。 然后您应该能够进行映射/等。然后进行断开连接的编辑并更改为实际参数值(我假设您是从全局变量获取它们)。
基本上,您可以像这样运行它,以便该过程返回结果。 进行映射,然后在断开连接的编辑中注释掉第二个
EXEC
并取消注释第一个EXEC
,它应该可以工作。基本上你只需要运行程序并输出结果。 即使您没有返回任何行,它仍然会正确映射列。 我无法访问我们的生产系统(甚至数据库)来创建 dts 包。 因此,我在虚拟数据库中创建它们,并将存储过程替换为返回与生产应用程序将运行的相同列的内容,但没有数据行。 然后,在映射完成后,我将其与真实程序一起移动到生产盒中,并且它可以工作。 如果您通过脚本跟踪数据库,这非常有用。 您可以运行该脚本来构建一个空外壳过程,完成后运行该脚本以放回真实的过程。
Enter some valid values for the stored procedure parameters so it runs and returns some data (or even no data, you just need the columns). Then you should be able to do the mapping/etc.. Then do a disconnected edit and change to the actual parameter values (I assume you are getting them from a global variable).
Basically you run it like this so the procedure returns results. Do the mapping, then in disconnected edit comment out the second
EXEC
and uncomment the firstEXEC
and it should work.Basically you just need to make the procedure run and spit out results. Even if you get no rows back, it will still map the columns correctly. I don't have access to our production system (or even database) to create dts packages. So I create them in a dummy database and replace the stored procedure with something that returns the same columns that the production app would run, but no rows of data. Then after the mapping is done I move it to the production box with the real procedure and it works. This works great if you keep track of the database via scripts. You can just run the script to build an empty shell procedure and when done run the script to put back the true procedure.