Solved

How can i cast integer to varchar

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

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
AS400 DAYOFWEEK(GENERAL DATE) 12 425
DB3-913 err can anyone plz help to solve this issue 3 268
DB2 return first match 3 122
DB2 Month between two dates 15 129
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…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

763 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