Re: No Decimal trailing sign



Stan,

You'll have to use string functions to do this.
Here's one solution:

declare @t table (
 d decimal(15,2)
)
insert into @t values (550.45)
insert into @t values (10000)
insert into @t values (-45.25)
insert into @t values (0)
insert into @t values (0.01)
insert into @t values (1)

select
 case when d >= 0
      then ltrim(cast(100*d as int))
 else ltrim(cast(-100*d as int)) + '-' end
from @t



Be sure you and the client agree on how to represent everything.
This solution represents 0 as '0', not '000', for example, which may
or may not be right.

Steve Kass
Drew University

Stan wrote:

I have a field defined as (decimal 9(15,2)) and the recipient of a conversion .txt file wants to see just the meaningful digits, no decimals, no zero fill but does want to see a trailing minus sign for negative numbers. So they want to see 550.45 as 55045 and -45.25 as 4525-.



.



Relevant Pages

  • Re: Another Understanding Pointers Question
    ... > string functions to test. ... but I just wanted to test writing my own functions. ... > int main ... Sorry if thats a dumb question.. ...
    (comp.lang.c)
  • Re: What does const char *s mean? is s a constant or *s?
    ... > I've been looking at some code for string functions (certain ... See what the compiler tells you when you try to compile it: ... int ch; ...
    (comp.lang.c)
  • Re: Convert to Hexidecimal
    ... Since you mentioned string functions, I'll guess that you want to ... create function hexchar( ... >I need to convert a numeric column into a hexidecimal format in a view. ...
    (microsoft.public.sqlserver.programming)
  • [PATCH] 2/2 Prezeroing large blocks of pages during allocation Version 4
    ... Have USERZERO and KERNZERO for different types of zero pages to avoid ... This is a patch that makes a step towards merging the modified allocator ... static inline void inc_reserve_count(struct zone *zone, ... +static inline void prep_zero_page(struct page *page, int order, int gfp_flags) ...
    (Linux-Kernel)
  • Re: edit and continue
    ... > Are you using the same sourcesafe I'm using. ... > safe crashing vb6. ... Zero random rollbacks (I can see why this would be a bad ... > int", the professional works on code daily and would much rather type "int ...
    (microsoft.public.vb.general.discussion)