简体   繁体   English

以编程方式使用SSIS执行SQL查询

[英]Executing a sql query using ssis programmatically

I am working on writing a program to generate SSIS package which executes a query on multiple databases. 我正在编写一个程序来生成SSIS包,该程序在多个数据库上执行查询。 I have already accomplished the task using a stored procedure however I don't want to use it. 我已经使用存储过程完成了任务,但是我不想使用它。 I have been struggling with Dts.runtime. 我一直在努力与Dts.runtime。 I am using C#. 我正在使用C#。

I have to read the query directly from the program and execute it, maybe using ExecuteSQLTask.Execute method. 我必须直接从程序中读取查询并执行它,也许使用ExecuteSQLTask.Execute方法。 I am totally stuck, or it could be that I am thinking in wrong direction all together. 我完全被困住了,或者可能是我在一起思考方向错误。

Please give me some insight into the problem. 请给我一些有关该问题的见解。

Just to be clear, the only execute method within Dts.Runtime is at the Package level. 需要明确的是,Dts.Runtime中唯一的 execute方法在Package级别。 You don't need to call ExecuteSQLTask.Execute (no such thing, by the way) or anything in your C#. 您不需要在C#中调用ExecuteSQLTask.Execute(顺便说一句,没有这种东西)。

Just build up your package's Executables, and then execute the package (or save it or whatever you want to do with it.) HINT: Use the SqlCommand property of the ExecuteSQLTask to set your command query from your program. 只需构建程序包的可执行文件,然后执行该程序包(或保存该程序包或执行任何操作)。提示:使用ExecuteSQLTask的SqlCommand属性可以从程序中设置命令查询。

You'll also probably want to look into EzApi which makes building packages programmatically in C# a lot easier. 您可能还想研究一下EzApi ,它使在C#中以编程方式构建软件包变得容易得多

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM