View Single Post

   
  #4 (permalink)  
Old 02-28-2008, 07:15 PM
pj
 
Posts: n/a
Default Re: Query Analyzer shows negative numbers as positive numbers

"Anith Sen" <anith@bizdatasolutions.com> wrote in message news:<7wMgb.4407$Eo2.1866@newsread2.news.atl.earth link.net>...
> Are you using seeing this with both Output to Text & Output to Grid options?


The field where I last noticed this is a decimal(15,2), so I
tried to simplify things and address your question as follows

********

create table atestneg (dollars decimal(15,2) null)
go
insert into atestneg (dollars) values (1)
go
insert into atestneg (dollars) values (-1)
go
insert into atestneg (dollars) values (-2)
go

select * from atestneg order by dollars

I see them, in grid view, with negative signs for the first two correctly.

Then I run an insert similar to this:

insert into atestneg(dollars)
select my_real_values from my_real_table
where my_real_values<0

select * from atestneg order by dollars


Now there are no negative signs, and the numbers appear to
go from highest to lowest, and then a 1 after the last one
(because of course they are really all negative except for
that last one).

I switched from "Results to grid" to "Results to text",
but still no negative signs.

I switched to "Results to file", ran it, gave a file name,
(drilled through a lot of annoying directories with spaces),
and found the file, and still no negative signs.


I tried instead, in Grid output mode now, this query

select * from atestneg where dollars<0 order by dollars

I still see the same thing (all my dollars descending except
for that trailing 1 which is really positive).

Copying & pasting from the grid output to OpenOffice Spreadsheet
or Microsoft Excel yields me a lot of numbers which still
look positive (and probably are, after the paste).


I wonder why the first three manually injected rows didn't
yield this problem behavior, but then adding a lot of
negative numbers to the same table did.
Reply With Quote