Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Numeric Field - Empty Digits Filled With Zeros??

Status
Not open for further replies.

SeaninSeattle

IS-IT--Management
Sep 17, 2001
53
0
0
US
Our bank wants reports - which is not a problem - but they want numeric fields that are completely filled - so that if a nine digit numeric is for 10.00 - it would appear like this: 00000010.00

How on earth do I do THAT??? :(

//sse

Sean Engle
Admin/DirIS
ssengle@bswusa.com
 
declare @money decimal(8,2)
set @money = 10.00
select right('0000000000'+cast(@money as varchar(20)),11)

in table form

select right('0000000000'+cast(money1 as varchar(10)),11) from tb1
 
Thanks Clare -

I thought I could just convert the numeric format to char and then somehow flood the empty spaces with '0'. But it seems I cannot even get past:

---------------

UPDATE COLUMBIA_UPLOAD
SET COLUMBIA_UPLOAD.CKAMNT = CONVERT(char(10), TRXAMNT,10)
FROM ##COLUMBIATMP
WHERE COLUMBIA_UPLOAD.CKSERIAL = ##COLUMBIATMP.CMTrxNum

---------------

It keeps overflowing. If I could just get this TRXAMNT out of numeric and into char I would be finished....

Thanks,
//sse

Sean Engle
Admin/DirIS
ssengle@bswusa.com
 
chnage
CONVERT(char(10), TRXAMNT,10)
to
convert(varchar(20),TRXAMNT)
 
Thanks Clare -

So I cannot go directly from numeric to char, eh? I addressed this by adding another field (varchar), and two-stepping it: numeric-->varchar-->char. It seems to work.

Hopefully I can get this off my desk now and get some lunch...

Thanks for your help! :)

//sse

Sean Engle
Admin/DirIS
ssengle@bswusa.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top