简体   繁体   English

不允许从数据类型varchar到varbinary(max)的隐式转换。 使用CONVERT

[英]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 SQL-服务器

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

MySQL MySQL的

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.

相关问题 不允许从数据类型varchar(max)隐式转换为varbinary(max)。 使用CONVERT函数运行此查询 - Implicit conversion from data type varchar(max) to varbinary(max) is not allowed. Use the CONVERT function to run this query 错误:不允许从数据类型varchar到varbinary(max)的隐式转换。 使用CONVERT函数运行此查询 - Error : Implicit conversion from data type varchar to varbinary(max) is not allowed. Use the CONVERT function to run this query OPENROWSET-不允许从数据类型varchar隐式转换为varbinary(max)。 使用CONVERT函数运行此查询 - OPENROWSET - Implicit conversion from data type varchar to varbinary(max) is not allowed. Use the CONVERT function to run this query 不允许从数据类型 varchar 到 varbinary 的隐式转换。 (SQL) - Implicit conversion from data type varchar to varbinary is not allowed. (SQL) INSERT查询错误:不允许从数据类型varchar到varbinary的隐式转换。 使用CONVERT函数运行此查询。 - INSERT query error: Implicit conversion from data type varchar to varbinary is not allowed. Use the CONVERT function to run this query. [SQL Server]不允许从数据类型nvarchar(max)到varbinary(max)的隐式转换。 使用CONVERT函数运行此查询 - [SQL Server]Implicit conversion from data type nvarchar(max) to varbinary(max) is not allowed. Use the CONVERT function to run this query 不允许从数据类型varchar到varbinary(max)的隐式转换 - Implicit conversion from data type varchar to varbinary(max) is not allowed 不允许从数据类型ntext到varchar的隐式转换。 使用CONVERT函数运行此查询 - Implicit conversion from data type ntext to varchar is not allowed. Use the CONVERT function to run this query 不允许从数据类型sql_variant隐式转换为varbinary(max)。 使用CONVERT函数运行此查询。 ASP.NET SQL数据源 - Implicit conversion from data type sql_variant to varbinary(max) is not allowed. Use the CONVERT function to run this query. ASP.NET SQL DataSource 在数据库中存储字节时出错,不允许从数据类型varchar到varbinary(max)的隐式转换 - Error while storing bytes in database ,Implicit conversion from data type varchar to varbinary(max) is not allowed
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM