Solved

How can i cast integer to varchar

Posted on 2010-11-08
5
675 Views
Last Modified: 2012-05-10
Hi,
SELECT cast(cont as varchar(255)) FROM aa;  is giving error.

Thanks
0
Comment
Question by:sam2929
5 Comments
 
LVL 7

Accepted Solution

by:
db2inst1 earned 500 total points
ID: 34086238
You could do the following

select char(cont) from aa;

If you really want varchar

select varchar(char(cont)) from aa;
0
 
LVL 18

Expert Comment

by:daveslash
ID: 34086346

Both of these work beautifully for me on DB2 for i (version 6.1)  -- DaveSlash


select varchar(anInteger)

from   MyTable



select cast(anInteger as varchar(255))

from   MyTable

Open in new window

0
 
LVL 37

Expert Comment

by:momi_sabag
ID: 34086351
Which error do u get?
0
 

Author Comment

by:sam2929
ID: 34086442
EE mobile sounds good
0
 
LVL 45

Expert Comment

by:Kdo
ID: 34086524

Dave's solutions work on LUW, too.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

November 2009 Recently, a question came up in the DB2 forum regarding the date format in DB2 UDB for AS/400.  Apparently in UDB LUW (Linux/Unix/Windows), the date format is a system-wide setting, and is not controlled at the session level.  I'm n…
Recursive SQL in UDB/LUW (it really isn't that hard to do) Recursive SQL is most often used to convert columns to rows or rows to columns.  A previous article described the process of converting rows to columns.  This article will build off of th…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now