Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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. 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. Use the CONVERT function to run this query.

I dont know how to implement the function CONVERT. Can anyone help me, please ?

like image 633
Murilo Avatar asked Nov 14 '13 13:11

Murilo


1 Answers

Use the convert function.

SELECT CONVERT(varchar(10), field_name) FROM table_name 
like image 155
Tobberoth Avatar answered Oct 04 '22 23:10

Tobberoth