带 sum 的 ssis 查找 - 无法映射参数
我有一个如下所示的 sql 查询:
SELECT SUM(A) AS expr1 FROM TREES WHERE (b = ?) AND (c = ?) and (d = ?)
如何映射参数?由于它是总和,因此我无法选择多行。
I have a sql query that looks like this:
SELECT SUM(A) AS expr1 FROM TREES WHERE (b = ?) AND (c = ?) and (d = ?)
How do I map the parameters? Since it's a sum, I can't select multiple rows.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
今天,类似的问题让我陷入了困境。映射参数很容易,但获取总和值可能会导致真正的问题。这是我在 SSIS 2008 中使用的设置。
我发现的要点:
这看起来像是一个 hack,但我能够对 WHERE 子句中的两个条件使用相同的输入列两次,并返回基于 SUM 的列和基于 COUNT 的列。
常规选项卡:
缓存模式:无缓存(因此我可以在高级选项卡上使用自定义查询)
连接类型:OLE DB 连接管理器
连接选项卡:
SQL查询的使用结果:勾选
查询:(有我的求和函数用于获取输出,但没有我的输入参数。查询将在“高级”选项卡上被覆盖,但我似乎需要在此处指定我的输出以便映射我的求和字段)
列选项卡:< /强>
映射您需要用作输入参数的列,以便它们在您的参数列表中可用。另请检查可用查找列的求和值,以便获得输出。您如何链接并不重要,因为“高级”选项卡将覆盖
高级选项卡:
修改检查的SQL语句。 (必须在“常规”选项卡上关闭缓存)
“参数”按钮:单击并映射参数。唯一可用的是我在“列”选项卡上使用的那些。同样,我在列选项卡上映射到的内容与它们的使用无关,只要我在这里正确使用它们即可。
就是这样,我能够使用参数进行输入,并在字段名称“CompanyFromSecurityNumber”和“FundCountForSecurityNumber”中获取我的汇总字段(MIN 和 COUNT)
A similar issue drove me up the wall today. Mapping the params is easy but then getting the summed value out may cause the real issues. So here are the settings I used in SSIS 2008.
Key points I found:
This seems like a hack but I was able to use the same input column twice for the two conditions in my WHERE clause and get back a column based on SUM and a column based on COUNT.
General Tab:
Cache mode: No cache (so I can used custom query on advanced tab)
Connection type: OLE DB connection manager
Connection Tab:
Use results of SQL query: checked
Query: (has my sum functions for getting output but not my input params. The query will get overwritten on the Advanced Tab but I seemed to need to specify my outputs here in order to map my summed fields)
Columns Tab:
Map the columns you need to use as params from your input so they are available in your param list. Also check the summed values for Available Lookup Columns so you get the outputs. How you link doesn't matter though sinnce the Advanced tab will overwrite
Advanced Tab:
Modify the SQL statement checked. (Had to have caching off on General Tab)
Parameters button: Click and map params. The only ones available were those I used on the Columns Tab. Again, what I mapped to on the columns tab had nothing to do with their use as long as I used them properly here.
So that was it and I was able to use the params for input and get my summarized fields (MIN and COUNT) out in fields name "CompanyFromSecurityNumber" and "FundCountForSecurityNumber"
尽管讨厌俄亥俄州的答案非常棒且完整,但对我来说,解决问题要简单得多。只需第一步,在连接选项卡上将源更改为 SQL 即可完成任务。
类似于:
然后,匹配列并将列映射到查找并完成。
Although Hating Ohio answer is awesome and complete, for me it was way simpler to solve the problem. Just the first step, changing the source to SQL on the connection tab did the job.
Something like:
Then, match the columns and map the columns to the lookups and done.