如何在 SSDT 2017 中将变量传递给 ODBC SQL 命令?

How to pass a variable to ODBC SQL Command in SSDT 2017?

我找不到将参数传递给 ODBC 源的选项?我可以看到很多与此相关的文章,但我在数据流任务表达式中找不到相同的选项。 [ODBC Source].[SqlCommand] 不在数据流任务中。

我引用的文章如下:

有人可以帮忙吗?

我认为 属性 丢失是由于 Visual Studio、SSDT 和 SQL 服务器版本 之间 不匹配。首先,您必须检查您使用的是相关且合适的版本,您可以检查以下link以获取更多信息:

同时尝试检查包 目标服务器版本:

类似问题links


更新 1

在搜索这个问题时,我发现 [ODBC Source].[SqlCommand] 属性 可能在 2012(2005,2008)之前的版本中找不到,但我发现 link 提到解决方法:

You can easily put in params if the source is an OLE DB source, but what if it is an ODBC Source? You have to use the DataReader source, and you can’t easily set params – like a WHERE statement. You HAVE to use Expressions in order to have a query with a dynamic WHERE statement or passing in a variable as WHERE statement filter.

So, throw a DataFlow on your package, and inside that, throw a DataReader source, and then set the connection to your ODBC Connection (ADO.NET Connection) and set the command text.