2012年3月27日星期二
Float Errors
CREATE TABLE TEST (COL1 FLOAT)
INSERT INTO TEST (COL1) VALUES (8746.02)
SELECT * FROM TEST
This is the result.
8746.0200000000004
How do I stop this from happening, I am inserting into someone else's system
so I can not change the data type.
Any help would be appreciated.
Thanks,
DanielSorry
SQL Server 2000 SP3
Dan
"Daniel Jeffrey" <daniel@.enprisesolutions.com> wrote in message
news:eFQtcyZ9DHA.2560@.TK2MSFTNGP09.phx.gbl...
> Simple way of testing this
> CREATE TABLE TEST (COL1 FLOAT)
> INSERT INTO TEST (COL1) VALUES (8746.02)
> SELECT * FROM TEST
> This is the result.
> 8746.0200000000004
> How do I stop this from happening, I am inserting into someone else's
system
> so I can not change the data type.
> Any help would be appreciated.
> Thanks,
> Daniel
>|||The problem is in the datatype. BOL will tell you that float is an approxim
ate datatype. Which means that the exact number stored is not always what w
as inteded for storage. There is no way to get around this unless you handl
e your own rounding (See Ro
und function in BOL). Even then you can get unexpected results.|||... so if you expect to get out what you put in, use an exact datatype, lik
e
a NUMERIC datatype, for instance.
Tibor Karaszi, SQL Server MVP
Archive at:
http://groups.google.com/groups?oi=...ublic.sqlserver
"Doug Guerena" <anonymous@.discussions.microsoft.com> wrote in message
news:5D884697-8F47-45A7-88A3-4E0B38DA61DF@.microsoft.com...
> The problem is in the datatype. BOL will tell you that float is an
approximate datatype. Which means that the exact number stored is not
always what was inteded for storage. There is no way to get around this
unless you handle your own rounding (See Round function in BOL). Even then
you can get unexpected results.|||Daniel,
The FLOAT data type can only represent finitely many of the
infinitely-many real numbers. The exact values FLOAT can represent are
those of the form N/power(2,k) where N is an integer with absolute value
between 2^52 and 2^53 and k is an integer between -930 and +1077 (or
something close to this - I didn't verify the exact details). The real
number 8746.02 cannot be written in that form, so the closest
representable float is inserted into the table.
So basically, whoever created the table TEST did not provide a place
to put the exact value 8746.02. If, however, you know that all values
inserted into TEST.COL1 were base-ten decimals with at most 10
significant digits and at most 2 decimal places, the value inserted can
be retrieved with SELECT CAST(COL1 AS DECIMAL(10,2)) FROM TEST, since
there is a unique decimal(10,2) that could have produced each value of
COL1 between -100000000.00 and 100000000.00 in the table.
SK
Daniel Jeffrey wrote:
>Simple way of testing this
>CREATE TABLE TEST (COL1 FLOAT)
>INSERT INTO TEST (COL1) VALUES (8746.02)
>SELECT * FROM TEST
>This is the result.
>8746.0200000000004
>How do I stop this from happening, I am inserting into someone else's syste
m
>so I can not change the data type.
>Any help would be appreciated.
>Thanks,
>Daniel
>
>|||I have found rounding issues with this operation as well
Float Errors
CREATE TABLE TEST (COL1 FLOAT)
INSERT INTO TEST (COL1) VALUES (8746.02)
SELECT * FROM TEST
This is the result.
8746.0200000000004
How do I stop this from happening, I am inserting into someone else's system
so I can not change the data type.
Any help would be appreciated.
Thanks,
DanielSorry
SQL Server 2000 SP3
Dan
"Daniel Jeffrey" <daniel@.enprisesolutions.com> wrote in message
news:eFQtcyZ9DHA.2560@.TK2MSFTNGP09.phx.gbl...
> Simple way of testing this
> CREATE TABLE TEST (COL1 FLOAT)
> INSERT INTO TEST (COL1) VALUES (8746.02)
> SELECT * FROM TEST
> This is the result.
> 8746.0200000000004
> How do I stop this from happening, I am inserting into someone else's
system
> so I can not change the data type.
> Any help would be appreciated.
> Thanks,
> Daniel
>|||The problem is in the datatype. BOL will tell you that float is an approximate datatype. Which means that the exact number stored is not always what was inteded for storage. There is no way to get around this unless you handle your own rounding (See Round function in BOL). Even then you can get unexpected results.|||... so if you expect to get out what you put in, use an exact datatype, like
a NUMERIC datatype, for instance.
--
Tibor Karaszi, SQL Server MVP
Archive at:
http://groups.google.com/groups?oi=djq&as_ugroup=microsoft.public.sqlserver
"Doug Guerena" <anonymous@.discussions.microsoft.com> wrote in message
news:5D884697-8F47-45A7-88A3-4E0B38DA61DF@.microsoft.com...
> The problem is in the datatype. BOL will tell you that float is an
approximate datatype. Which means that the exact number stored is not
always what was inteded for storage. There is no way to get around this
unless you handle your own rounding (See Round function in BOL). Even then
you can get unexpected results.|||Daniel,
The FLOAT data type can only represent finitely many of the
infinitely-many real numbers. The exact values FLOAT can represent are
those of the form N/power(2,k) where N is an integer with absolute value
between 2^52 and 2^53 and k is an integer between -930 and +1077 (or
something close to this - I didn't verify the exact details). The real
number 8746.02 cannot be written in that form, so the closest
representable float is inserted into the table.
So basically, whoever created the table TEST did not provide a place
to put the exact value 8746.02. If, however, you know that all values
inserted into TEST.COL1 were base-ten decimals with at most 10
significant digits and at most 2 decimal places, the value inserted can
be retrieved with SELECT CAST(COL1 AS DECIMAL(10,2)) FROM TEST, since
there is a unique decimal(10,2) that could have produced each value of
COL1 between -100000000.00 and 100000000.00 in the table.
SK
Daniel Jeffrey wrote:
>Simple way of testing this
>CREATE TABLE TEST (COL1 FLOAT)
>INSERT INTO TEST (COL1) VALUES (8746.02)
>SELECT * FROM TEST
>This is the result.
>8746.0200000000004
>How do I stop this from happening, I am inserting into someone else's system
>so I can not change the data type.
>Any help would be appreciated.
>Thanks,
>Daniel
>
>|||I have found rounding issues with this operation as wellsql
2012年3月9日星期五
fix DBCC CHECKCATALOG errors
that exists objects (in sys.columns) without depend views. In SQL 2000 I can
edit direct sysobject table. How delete orphaned objects in SQL 2005? Only
way is copy data to new database?I wouldn't think editing sysobjects is a real good idea, unless you're very
(very) sure.
However, since CHECKCATALOG is part of CHECKDB, I would assume you would
used CHECKDB to repair any problems.
"Waldemar Grzywiñski" <waldemarg@.autograf.pl> wrote in message
news:evNoNT%23JIHA.5684@.TK2MSFTNGP06.phx.gbl...
> How to fix system tables integrity errors? DBCC CHECKCATALOG points
> that exists objects (in sys.columns) without depend views. In SQL 2000 I
> can edit direct sysobject table. How delete orphaned objects in SQL 2005?
> Only way is copy data to new database?
>
fix DBCC CHECKCATALOG errors
that exists objects (in sys.columns) without depend views. In SQL 2000 I can
edit direct sysobject table. How delete orphaned objects in SQL 2005? Only
way is copy data to new database?I wouldn't think editing sysobjects is a real good idea, unless you're very
(very) sure.
However, since CHECKCATALOG is part of CHECKDB, I would assume you would
used CHECKDB to repair any problems.
"Waldemar Grzywiski" <waldemarg@.autograf.pl> wrote in message
news:evNoNT%23JIHA.5684@.TK2MSFTNGP06.phx.gbl...
> How to fix system tables integrity errors? DBCC CHECKCATALOG points
> that exists objects (in sys.columns) without depend views. In SQL 2000 I
> can edit direct sysobject table. How delete orphaned objects in SQL 2005?
> Only way is copy data to new database?
>
2012年3月7日星期三
First time setting up SQL MSDE, trouble loggin in...
I also get an error when trying to connect using Web Data Administrator: "Invalid username and/or password, or server does not exist. Also, please ensure that SQL Server Authentication is enabled on the server. " I am using the "sa" account with the correct password. I have also tried no password (just in case) and that doesn't work either.
I cannot confirm that I have SQL Server Authentication enabled. I have no idea how to check for this using SQL MSDE. This may be part of the problem...any thoughts on this issue?
My OS: Windows XP Professional Service Pack 1 (Build 2600)
My Web Server: Internet Information Services Version 5.1.2600.0
My .NET Framework: .NET Framework Version 1.1.4322.573
My SQL Server: Microsoft SQL Server Desktop Engine (SQL Server Version 8.00.760)
Other Info: .NET is fine and linked to IIS, all other .NET apps compile/run fine. SQL Server Service Manager is giving me the green arrow. My OS is MS WinXP Pro, all SP's and hot fixes and updates applied.
I will be monitoring this post and trying any suggestions right away & posting my success/failure right back here.
If anyone would like to see a screen shot of the error generated by the Time Tracker install, use the following link:
http://www.versyss.com/mike/shot.gif
Thanks in advance!First, to determine with authentication mode you are using, go to the Windows command prompt and type this command:
osql -d Master -Q "xp_loginconfig" -E
Terri|||Results of: osql -d Master -Q "xp_loginconfig" -E
Name: Config_Value
--------
login mode:Windows NT Authentication
default login:guest
default domain:Null
audit level:none
set hostname:false
map _ :domain separator
map $:Null
map #:-
So it looks like I am using Win. NT Auth. mode. Now how do I switch this to SQL Server Auth. or Mixed Mode? Remember this is a MSDE installation so I have no Enterprise Manager...
Thanks sof the help so far....Mike|||Without Enterprise Manager, you could edit the registry:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSSQLServer\MSSQLServer
Change LoginMode to 1 for "Windows Only", 2 for "SQL Server and Windows"
As always, use care when editing the registry. It should be backed up first. If you've never edited the registry, you should read up on it first. I claim no responsibility!
Terri|||Terri, you RULE!
It worked. I edited the reg value you indicated, rebooted, ran "osql -d Master -Q "xp_loginconfig" -E" and verified my mode (which now reads "mixed") and was able to log into my server using Web Data Admin! Thanks so much! I hope this posts helps some other people as well!
P.S. The use of "localhost" didn't work for the server. I think I read somewhere that the "localhost" option has been disabled in MSDE. I don't know for sure but all I know is that "localhost" didn't work for me but the server name and IP address do...
Thanks again Terri...