Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

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…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

598 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