Solved

How can i cast integer to varchar

Posted on 2010-11-08
5
679 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

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 (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…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

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