您将需要
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)
您的原始查询的语法向后。



