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 2000 Forums
 Transact-SQL (2000)
 format column

Author  Topic 

jung1975
Aged Yak Warrior

503 Posts

Posted - 2004-08-12 : 22:01:09
I have a column A

A
---
103.00
101.
102.01
111.0
123.98

I would like to get rid of .00 and .0
so, the output should look like

A
--
103.
101.
102.01
111.
123.98


Should I use a CASE statement for this case?




timmy
Master Smack Fu Yak Hacker

1242 Posts

Posted - 2004-08-12 : 22:07:07

Why can't you do the formatting in your presentation layer?
Go to Top of Page

Lumbago
Norsk Yak Master

3271 Posts

Posted - 2004-08-13 : 03:41:05
Data formatting is always done in the presentation-layer but it does look kind of strange. Is ColumnA some sort of string? If they were numbers (like decimal(6, 2)) I belive they would all be stored with two decimals...hm, maybe not...
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2004-08-13 : 05:33:46
maybe something like this:

select replace(field, '.00', '.')
from MyTable
where field like '%.00'

select replace(field, '.0', '.')
from MyTable
where field like '%.0'

Go with the flow & have fun! Else fight the flow :)
Go to Top of Page
   

- Advertisement -