将int转换为varchar

将int转换为varchar,第1张

将int转换为varchar

您将需要

cast
convert
作为
CHAR
数据类型,没有
varchar
可以将数据强制转换/转换为以下数据的数据类型:

select CAST(id as CHAr(50)) as col1 from t9;select ConVERT(id, CHAr(50)) as colI1 from t9;

请参阅下面的SQL(实际上)在SQL
Fiddle中

create table t9 (id INT, name VARCHAr(55));insert into t9 (id, name) values (2, 'bob');select CAST(id as CHAr(50)) as col1 from t9;select ConVERT(id, CHAr(50)) as colI1 from t9;

除了您试图转换为不正确的数据类型外,您所使用的语法也不

convert
正确。该
convert
函数使用以下列
expr
或值:

 ConVERT(expr,type)

要么

 ConVERT(expr USING transcoding_name)

您的原始查询的语法向后。



欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/zaji/4976156.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-11-14
下一篇2022-11-13

发表评论

登录后才能评论

评论列表(0条)

    保存