[英]Implicit conversion from data type varchar to varbinary(max) is not allowed. Use the CONVERT
I am getting the following error: 我收到以下错误:
"Implicit conversion from data type varchar to varbinary(max) is not allowed. Use the CONVERT function to run this query."
“不允许从数据类型varchar到varbinary(max)的隐式转换。使用CONVERT函数运行此查询。”
Note: 注意:
@transientCartData
is defined as varbinary(max)
@transientCartData
定义为varbinary(max)
@savedCartData
is defined as varbinary(max)
@savedCartData
定义为varbinary(max)
The query: 查询:
exec [ecomm].[expiry_save_cart2_v1]
@id=80094,
@lastUpdated='2016-05-11 14:23:42.637',
@transientCartExpiryIntervalInMin='45',
@session_id='5C632166-D7D6-4F51-A87F-EED41376EEA7',
@version='TEST_VERSION',
@associated_slots='Null',
@account_id='TEST_ACCOUNT_ID',
@cookie='Null',
@transientCartData= 'TEST_DATA',
@savedCartData= 'TEST_DATA',
@data2='NULL',
@is_pricing_needed='1',
@savedCartExpiryIntervalInDays='14',
@persistentCartExpiryIntervalInDays='1',
@cart_type='PERSISTENT',
@customerAccountId=TEST_ACCOUNT_ID
Then when I am trying to use @transientCartData = CONVERT(varbinary, 'TEST_DATA', 1)
, I am getting this error: 然后,当我尝试使用
@transientCartData = CONVERT(varbinary, 'TEST_DATA', 1)
,我收到此错误:
Incorrect syntax near the keyword 'CONVERT'.
关键字“CONVERT”附近的语法不正确。
SQL-Server has the following syntax for Convert . SQL-Server具有以下Convert语法。
CONVERT ( data_type [ ( length ) ] , expression [ , style ] )
CONVERT(data_type [(length)],表达式[,style])
You code is failing due to style being set as 1 . 由于样式设置为1,您的代码失败。
If the data_type is a binary type, the expression must be a character expression.
如果data_type是二进制类型,则表达式必须是字符表达式。 The expression must be composed of an even number of hexadecimal digits (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F, a, b, c, d, e, f).
表达式必须由偶数个十六进制数字组成(0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F,a,b,c ,d,e,f)。 ...
...
You need to set it to 0 (default). 您需要将其设置为0 (默认值)。
Translates ASCII characters to binary bytes or binary bytes to ASCII characters...
将ASCII字符转换为二进制字节或二进制字节转换为ASCII字符......
Example convert usage, which produces 0x544553545F44415441 示例转换用法,产生0x544553545F44415441
Declare @vb as varbinary(max)
Set @vb = CONVERT(varbinary(max), 'TEST_DATA', 0)
select @vb
According to the documentation for Convert your method signature is incorrect. 根据转换的文档,您的方法签名不正确。
CONVERT has the following MySQL syntax: CONVERT具有以下MySQL语法:
CONVERT(expr,type), CONVERT(expr USING transcoding_name)
CONVERT(expr,type),CONVERT(expr USING transcoding_name)
Calling a stored procedure uses Call in MySQL. 调用存储过程使用MySQL中的Call 。
CALL sp_name([parameter[,...]])
CALL sp_name([parameter [,...]])
An example of the usage is: 用法的一个例子是:
mysql> SET @increment = 10;
mysql> CALL p(@version, @increment);
mysql> SELECT @version, @increment;
+--------------+------------+
| @version | @increment |
+--------------+------------+
| 5.5.3-m3-log | 11 |
+--------------+------------+
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.