?
Solved

How can i cast integer to varchar

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

Thanks
0
Comment
Question by:sam2929
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 7

Accepted Solution

by:
db2inst1 earned 2000 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:Dave Ford
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 46

Expert Comment

by:Kent Olsen
ID: 34086524

Dave's solutions work on LUW, too.
0

Featured Post

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

Question has a verified solution.

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

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…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

752 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