Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 SQL Server/Oracle CAST problem

Author  Topic 

DBASlut
Yak Posting Veteran

71 Posts

Posted - 2008-06-26 : 12:39:48
i have a linked Oracle database that has a view that I use. One of the fields is a NUMBER field in ORACLE. I want to convert the field to a VARCHAR and append some leading zeros to it. But when I CAST the field to a VARCHAR, it gives me the following:
OriginalValue CastedValue
2718525 2.71853e+006

My cast code is CAST(OriginalValue AS VARCHAR(25))
What am I doing wrong?

DBASlut
Yak Posting Veteran

71 Posts

Posted - 2008-06-26 : 12:49:32
hmmm.. i used CONVERT(INT,OriginalValue) and it worked.
i just wanted to avoid doing 2 function calls, ie.
'0000' + CAST(ORIGINALVALUE AS VARCHAR(225))
instead of
'0000' + CAST(CONVERT(INT,ORGINALVALUE) AS VARCHAR(225))
Go to Top of Page
   

- Advertisement -