在SSIS中使用OLE DB COMMAND的查询中的多个参数 [英] Multiple parameters in a query using a OLE DB COMMAND in SSIS

查看:274
本文介绍了在SSIS中使用OLE DB COMMAND的查询中的多个参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用OLE DB命令在SSIS中进行此更新:

I am trying to do this update in SSIS using a OLE DB COMMAND:

UPDATE 
TABLE_A
SET 
COLUMN_C = CONCAT(?,' ',?)
FROM 
TABLE_A INNER JOIN TABLE_B ON
TABLE_A.ID = TABLE_B.ID

但是当我尝试映射参数时,我收到此消息:

But when I try to map the parameters I am getting this message:

无法推导出参数类型,因为单个表达式包含两个未键入的参数"

"the parameter type cannot be deduced because a single expression contains two untyped parameters"

我不知道我在此查询中是否做错了什么,或者是否不可能在一个句子中使用多个参数.

I do not know if I am doing something wrong with this query or if it is not possible to use more than one parameter in one single sentence.

我正在使用VS 2010

I am using VS 2010

推荐答案

使用SQL Server 2012及更高版本进行参数绑定

Parameter Binding with SQL Server 2012 and later

SQL Server 2012和更高版本已更改了SQL解析器或优化器,以使用更严格的方法来确定未知的参数输入类型.

SQL Server 2012 and later have changed the SQL parser or optimizer to use a more stringent method of determining the unkown parameter input types.

这将导致SQL语句,例如"WHERE col1> =?+?"失败并出现诸如mx.ODBC.Error.ProgrammingError之类的错误:('42000',11503,"[Microsoft] [SQL Server的ODBC驱动程序11] [SQL Server]无法推导出参数类型,因为单个表达式包含两个无类型参数"@ P1"和"@ P2".",10191).

This results in SQL statements such as "WHERE col1 >= ? + ?" to fail with an error such as mx.ODBC.Error.ProgrammingError: ('42000', 11503, "[Microsoft][ODBC Driver 11 for SQL Server][SQL Server]The parameter type cannot be deduced because a single expression contains two untyped parameters, '@P1' and '@P2'.", 10191).

解决方案

  1. 使用显式强制类型转换来告诉SQL解析器右侧操作需要哪种类型,例如"WHERE col1> =?+ CAST(?作为int)".这为第二个参数提供了一个显式类型,并允许解析器推断结果的类型,

这篇关于在SSIS中使用OLE DB COMMAND的查询中的多个参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆