Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
192 views
in Technique[技术] by (71.8m points)

sql - 将INT转换为VARCHAR SQL(Convert INT to VARCHAR SQL)

I am using Sybase and I am doing a select which returns me a column called "iftype", but its type is int and I need to convert into varchar.

(我正在使用Sybase,我正在做一个select,它返回一个名为“iftype”的列,但它的类型是int,我需要转换为varchar。)

When I try to do the select without the convert function I get this error:

(当我尝试在没有转换功能的情况下进行选择时,我收到此错误:)

Error code 257, SQL state 37000: Implicit conversion from datatype 'VARCHAR' to 'INT' is not allowed.

(错误代码257,SQL状态37000:不允许从数据类型“VARCHAR”到“INT”的隐式转换。)

Use the CONVERT function to run this query.

(使用CONVERT函数运行此查询。)

I dont know how to implement the function CONVERT .

(我不知道如何实现CONVERT函数。)

Can anyone help me, please ?

(有人可以帮帮我吗?)

  ask by Murilo translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

使用转换功能。

SELECT CONVERT(varchar(10), field_name) FROM table_name

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...