How can i cast integer to varchar

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

Question by:sam2929
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

Accepted Solution

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;
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

LVL 37

Expert Comment

ID: 34086351
Which error do u get?

Author Comment

ID: 34086442
EE mobile sounds good
LVL 46

Expert Comment

by:Kent Olsen
ID: 34086524

Dave's solutions work on LUW, too.

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