Home > Archive > microsoft.public.sqlserver.server > June 2002 > Creating custom field view





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Creating custom field view
ddebow

2002-06-22, 8:31 pm

I am creating a custom view in a database. There is a
currency field that I need to reformat somehow. I need to
remove the decimal point without removing the integer or
decimal values. Example:

Currency Field

0.00
10.00
15.50
200.45

Reformatted

000
1000
1550
20045

Does anyone know a formula to accomplish this? Thanks

Tibor Karaszi

2002-06-22, 8:32 pm

How about converting to money. Then to a string, using the appropriate 3:rd parameter of the
convert command. Then just remove the ".".

SELECT
CAST(val AS money),
CONVERT(varchar(20), CAST(val AS money), 0),
REPLACE(CONVERT(varchar(20), CAST(val AS money), 0), '.', '')
FROM
(SELECT 10.00 AS val
UNION
SELECT 0.00
UNION
SELECT 15.50
UNION
SELECT 200.45) as inr
--
Tibor Karaszi, SQL Server MVP
Archive at: http://groups.google.com/groups?oi=...ublic.sqlserver


"ddebow" <ddebow@mcskc.com> wrote in message news:dd0301c211a0$623623b0$39e
f2ecf@TKMSFTNGXA08...
> I am creating a custom view in a database. There is a
> currency field that I need to reformat somehow. I need to
> remove the decimal point without removing the integer or
> decimal values. Example:
>
> Currency Field
>
> 0.00
> 10.00
> 15.50
> 200.45
>
> Reformatted
>
> 000
> 1000
> 1550
> 20045
>
> Does anyone know a formula to accomplish this? Thanks
>



Sponsored Links





Free Braindumps | MCSE braindumps software forum

Copyright 2003 - 2008 examnotes.net