473,748 Members | 8,530 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Query Analyzer shows negative numbers as positive numbers

pj
Why does M$ Query Analyzer display all numbers as positive, no matter
whether they are truly positive or negative ?

I am having to cast each column to varchar to find out if there are
any negative numbers being hidden from me :(

I tried checking Tools/Options/Connections/Use Regional Settings both
on and off, stopping and restarting M$ Query Analyer in betwixt, but
no improvement.

Am I missing some other option somewhere ?
Jul 20 '05 #1
7 8223
Are you using seeing this with both Output to Text & Output to Grid options?

--
--- Anith
Jul 20 '05 #2
pj (pe************ @hotmail.com) writes:
Why does M$ Query Analyzer display all numbers as positive, no matter
whether they are truly positive or negative ?

I am having to cast each column to varchar to find out if there are
any negative numbers being hidden from me :(

I tried checking Tools/Options/Connections/Use Regional Settings both
on and off, stopping and restarting M$ Query Analyer in betwixt, but
no improvement.

Am I missing some other option somewhere ?


I have never had any problems with QA not showing negative numbers.

If you run your query from command-line ISQL, do you seen negative
numbers there?
--
Erland Sommarskog, SQL Server MVP, so****@algonet. se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 20 '05 #3
pj
"Anith Sen" <an***@bizdatas olutions.com> wrote in message news:<7w******* **********@news read2.news.atl. earthlink.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(dollar s)
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.
Jul 20 '05 #4
pj
Erland Sommarskog <so****@algonet .se> wrote in message news:<Xn******* **************@ 127.0.0.1>...
pj (pe************ @hotmail.com) writes:
Why does M$ Query Analyzer display all numbers as positive, no matter
whether they are truly positive or negative ?

I am having to cast each column to varchar to find out if there are
any negative numbers being hidden from me :(

I tried checking Tools/Options/Connections/Use Regional Settings both
on and off, stopping and restarting M$ Query Analyer in betwixt, but
no improvement.

Am I missing some other option somewhere ?


I have never had any problems with QA not showing negative numbers.

If you run your query from command-line ISQL, do you seen negative
numbers there?


I get nothing back with ISQL (using "select * from atestneg" from
my example posted in the other thread), but if I use OSQL, then
"select * from atestneg where dollars<0 order by dollars" yields me
the list of apparently positive numbers in descending order -- so
whatever ordered them understood that they were negative, but I don't
know if the client is getting them as negative and just showing
them incorrectly, or if the client is misunderstandin g them as
positive.
Jul 20 '05 #5
pj (pe************ @hotmail.com) writes:
Then I run an insert similar to this:

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

select * from atestneg order by dollars


Since we don't have you real table and values it is difficult to
reproduce. Could you try this script:

drop table atestneg
go
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
insert into atestneg (dollars)
select Freight - 10
FROM Northwind..Orde rs
where Freight < 10
go
select * from atestneg order by dollars

and report what you see. (Preferably by including the output as
attachment.) Please run both in Query Analyzer and in OSQL and ISQL.
To run from the latter, save in a file and say:

ISQL -E -d tempdb -n -i atestneg.sql > atestneg.out

You mentioned that you did not get any output from ISQL, this sounds
funny.

Also if you can, try running against the same SQL Server from different
machines, and try running with your machine against other SQL Servers.

I have no idea of what's going on. But it seems that either something
is very funky with your data, or something is very funy with either
the server or client machine. I have actually seen an example of the latter,
although in that situation the problem was that the decimal point appeared
to be ignored on input. (This culprit then was running SQL Mail with
Outlook as mail client, if I remember correctly.)

--
Erland Sommarskog, SQL Server MVP, so****@algonet. se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 20 '05 #6
Erland Sommarskog <so****@algonet .se> wrote in message news:<Xn******* **************@ 127.0.0.1>...
pj (pe************ @hotmail.com) writes:
Then I run an insert similar to this:

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

select * from atestneg order by dollars


Since we don't have you real table and values it is difficult to
reproduce. Could you try this script:

drop table atestneg
go
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
insert into atestneg (dollars)
select Freight - 10
FROM Northwind..Orde rs
where Freight < 10
go
select * from atestneg order by dollars

and report what you see. (Preferably by including the output as
attachment.) Please run both in Query Analyzer and in OSQL and ISQL.
To run from the latter, save in a file and say:

Server: Msg 3701, Level 11, State 5, Line 1
Cannot drop the table 'atestneg', because it does not exist in the system catalog.

(1 row(s) affected)
(1 row(s) affected)
(1 row(s) affected)

Server: Msg 208, Level 16, State 1, Line 1
Invalid object name 'Northwind..Ord ers'.
Obviously this is going to fail in isql & osql as well,
because of the reference to the nonexistent table Northwind..Orde rs.
:(
Jul 20 '05 #7
horton (ho**********@y ahoo.com) writes:
Erland Sommarskog <so****@algonet .se> wrote in message

news:<Xn******* **************@ 127.0.0.1>...
Since we don't have you real table and values it is difficult to
reproduce. Could you try this script:

drop table atestneg
go
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
insert into atestneg (dollars)
select Freight - 10
FROM Northwind..Orde rs
where Freight < 10
go
select * from atestneg order by dollars

and report what you see. (Preferably by including the output as
attachment.) Please run both in Query Analyzer and in OSQL and ISQL.
To run from the latter, save in a file and say:


...

Server: Msg 208, Level 16, State 1, Line 1
Invalid object name 'Northwind..Ord ers'.
Obviously this is going to fail in isql & osql as well,
because of the reference to the nonexistent table Northwind..Orde rs.
:(


Northwind is an example database that ships with SQL Server since
version 7. If you don't have Northwind..Orde rs on your server, you
are either running SQL 6.5, or you have for some reason removed
Northwind from the server or at least dropped the Orders table in
it.

In in the Install directory for SQL Server you can find the file
instnwnd.sql that installs Northwind.

--
Erland Sommarskog, SQL Server MVP, so****@algonet. se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 20 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
28971
by: deko | last post by:
Is there an easy way to make all negative values positive in a particular table? I've been experimenting with this: Dim rst As DAO.Recordset Set rst = db.OpenRecordset("tblNegValues") Do If rst!Amount < 0 Then rst!Amount = rst!Amount - (rst!Amount * 2)
5
6119
by: Subrahmanyam Arya | last post by:
Hi Folks , I am trying to solve the problem of reading the numbers correctly from a serial line into an intel pentium processor machine . I am reading 1 byte and 2byte data both positive and negative quantities . Can any one tell me what are the things i should bear in mind .
3
1891
by: abighill | last post by:
Problem ------------- I want to return all URL records from 'fett_url' that are not currently indexed in the lookup table 'fett_url_to_data' where 'data_id=2'. i.e. fields=> url_id, url_title, url_link, url_description
15
35508
by: jaks.maths | last post by:
How to convert negative integer to hexadecimal or octal number? Ex: -568 What is the equivalent hexadecimal and octal number??
11
3730
by: drtimhill | last post by:
I'm just starting out on Python, and am stumped by what appears an oddity in the way negative indices are handled. For example, to get the last character in a string, I can enter "x". To get the 2nd and 3rd to last, I can enter x etc. This is fine. Logically, I should be able to enter x to get the last and next to last characters. However, since Python doesn't distinguish between positive and negative zero, this doesn't work. Instead, I...
39
4011
by: Frederick Gotham | last post by:
I have a general idea about how negative number systems work, but I'd appreciate some clarification if anyone would be willing to help me. Let's assume we're working with an 8-Bit signed integer, and that it contains no padding. Firstly, I realise that the MSB is known as the sign-bit, and that it indicates whether the number is positive or negative (irrespective of which negative number system is used).
19
11540
by: Johs | last post by:
I need to make some special action if 'a' and 'b' are both positive or both negative. Is there some inbuilt function to check this? Johs
10
1989
by: johnewing | last post by:
I am trying to figure out how to test if two numbers are of the same sign (both positive or both negative). I have tried abs(x) / x == abs(y) / y but that fails when one of the numbers is 0. I'm sure that there is an easy way to do this. Any suggestions? Thanks
0
1412
lee123
by: lee123 | last post by:
i am making a program that is about algebra and i want to know how can i get it to put negative and positive numbers in a text box for example if i had a problem that is: -6(2x + 10) = -48, -12x + 60 = -48 in my project i have 6 textboxes for the numbers and two of them are for "X" if the problem has the "X" after the 10 anyway in this project i show the steps for figuring thes problems out right down to the answer.(with labels...
0
8989
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8828
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9537
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9367
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9319
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6795
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4869
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3309
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2780
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.