如何在SSIS中为OLE DB连接使用变量 [英] How can I use a Variable for a OLE DB Connection in SSIS
问题描述
是否可以使用用户定义的变量为SSIS OLE DB连接定义连接字符串?
Is there a way to use a user defined variable to define a connection string for an SSIS OLE DB Connection?
1)我最初将其设置为使用包参数.
1) I had originally set it up to use a package parameter.
2)我在SQL存储过程中使用xp_cmdshell从文件执行SSIS包,但发现该包参数是只读的.
2) I execute the SSIS Package from a file using xp_cmdshell in a SQL stored proc, but found out that package Parameters are read only.
- 我遇到了此错误...更改变量的值失败,因为它是参数变量.参数变量是只读的"
3)看来我需要使用变量...但是,我没有看到为连接字符串使用变量的方法.当我使用"Parameterize"选项进行连接时,它仅使我可以选择一个参数,而不是变量.
3) So it looks like I need to use variables... However, I don't see a way to use a variable for the connection string. When I use the 'Parameterize' option for the connection, it only gives me the option to select a parameter, not a variable.
有什么想法吗?谢谢!
推荐答案
我确信从注释中您会得到很多建议,但是您问如何使用变量作为连接字符串,以便回答部分.很简单,
I am sure from the comments that you are going to get a lot of advice but you asked how do you use a variable as a connection string so to answer that part. It is fairly easy,
- 添加Package变量(在空白处的控制流中单击鼠标右键,然后选择变量将使您可以在其中添加一个变量)
- 选择连接管理器,然后转到属性(我使用右键单击属性)
- 单击表达式",然后单击...按钮
- 在属性"中选择"ConnectionString",然后将表达式设置为变量或所需的任何值.
这篇关于如何在SSIS中为OLE DB连接使用变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!