Solved

How can i cast integer to varchar

Posted on 2010-11-08
5
681 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:Kent Olsen
ID: 34086524

Dave's solutions work on LUW, too.
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Find Value column 2 does not work 1 196
AS400 DAYOFWEEK(GENERAL DATE) 12 409
The Event Monitor "DB2DETAILDEADLOCK" has reached its file 7 378
Monitor SQL Insert 8 74
Recursive SQL in UDB/LUW (you can use 'recursive' and 'SQL' in the same sentence) A growing number of database queries lend themselves to recursive solutions.  It's not always easy to spot when recursion is called for, especially for people una…
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…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

831 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