Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 711
  • Last Modified:

How can i cast integer to varchar

Hi,
SELECT cast(cont as varchar(255)) FROM aa;  is giving error.

Thanks
0
sam2929
Asked:
sam2929
1 Solution
 
db2inst1Commented:
You could do the following

select char(cont) from aa;

If you really want varchar

select varchar(char(cont)) from aa;
0
 
Dave FordSoftware Developer / Database AdministratorCommented:

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
 
momi_sabagCommented:
Which error do u get?
0
 
sam2929Author Commented:
EE mobile sounds good
0
 
Kent OlsenData Warehouse Architect / DBACommented:

Dave's solutions work on LUW, too.
0

Featured Post

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now