how can i assigned a float number with only one digit after the dot to the DB ?
i mean that i want to write this number 0.1 and not this 0.100000000 (that
what the sql does for me now..)
im using a storage procedure for this purpuse, so maybe the problem is there..
thanks !!
Hello,
Use Numeric instead of FLOAT datatype.
Thanks
Hari
"guy" <guy@.discussions.microsoft.com> wrote in message
news:04D80E57-189C-4C31-8729-1511B073B490@.microsoft.com...
> how can i assigned a float number with only one digit after the dot to the
> DB ?
> i mean that i want to write this number 0.1 and not this 0.100000000 (that
> what the sql does for me now..)
> im using a storage procedure for this purpuse, so maybe the problem is
> there..
> thanks !!
>
|||but if its Numeric it cant save me the 0.1 ... (or maybe i dont know how to
do this..) it save it like it was zero..
"Hari Prasad" wrote:
> Hello,
> Use Numeric instead of FLOAT datatype.
> Thanks
> Hari
> "guy" <guy@.discussions.microsoft.com> wrote in message
> news:04D80E57-189C-4C31-8729-1511B073B490@.microsoft.com...
>
>
|||Hello,
Use the below sample:-
declare @.t numeric(2,1)
set @.t = 0.1
select @.t
Thanks
Hari
"guy" <guy@.discussions.microsoft.com> wrote in message
news:590D1DF2-C360-45BB-9675-52533F59AABC@.microsoft.com...[vbcol=seagreen]
> but if its Numeric it cant save me the 0.1 ... (or maybe i dont know how
> to
> do this..) it save it like it was zero..
> "Hari Prasad" wrote:
|||On Sat, 23 Jun 2007 01:38:00 -0700, guy wrote:
>how can i assigned a float number with only one digit after the dot to the DB ?
>i mean that i want to write this number 0.1 and not this 0.100000000 (that
>what the sql does for me now..)
>im using a storage procedure for this purpuse, so maybe the problem is there..
>thanks !!
Hi Guy,
The only difference between 0.1 and 0.100000 is representation; their
values are exactyl equal. Since the internal representation for numeric
datatypes is different from what you see anyway, this question really
can't be answered. Whether you assign 0.1, 0.10000 or 0.2/2 to a float
variable or column, the result will always be the same.
So, if you want to STORE numbers with only one decimal place, then
Hari's answer is correct - you can't do that with float numbers, but you
can with the datatype numeric. If, on the other hand, you want to store
float numbers but REPRESENT them with one digit after the decimal place,
check out the subjects STR and CONVERT in Books Online. Note that these
functions convert a float value to a string representation, so the value
is no longer considered a number after this conversion!
Hugo Kornelis, SQL Server MVP
My SQL Server blog: http://sqlblog.com/blogs/hugo_kornelis
Showing posts with label float. Show all posts
Showing posts with label float. Show all posts
Wednesday, March 28, 2012
Friday, March 23, 2012
How to alter a column
Hi,
What's wrong with the following code? Please help. I am using MS SQL
2000.
create table one (
a float NOT NULL,
b varchar (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
)
alter table one
alter column a {drop} NOT NULL
alter column b {drop} NOT NULL
;
Thanks,
MikeSyntax usage is incorrect. Please use the below code to modify NOT NULL to NULL
alter table one alter column a Float NULL
alter table one alter column b Varchar(50) NULL
Thanks
Hari
"Michael" wrote:
> Hi,
> What's wrong with the following code? Please help. I am using MS SQL
> 2000.
> create table one (
> a float NOT NULL,
> b varchar (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
> )
> alter table one
> alter column a {drop} NOT NULL
> alter column b {drop} NOT NULL
> ;
> Thanks,
> Mike
>
What's wrong with the following code? Please help. I am using MS SQL
2000.
create table one (
a float NOT NULL,
b varchar (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
)
alter table one
alter column a {drop} NOT NULL
alter column b {drop} NOT NULL
;
Thanks,
MikeSyntax usage is incorrect. Please use the below code to modify NOT NULL to NULL
alter table one alter column a Float NULL
alter table one alter column b Varchar(50) NULL
Thanks
Hari
"Michael" wrote:
> Hi,
> What's wrong with the following code? Please help. I am using MS SQL
> 2000.
> create table one (
> a float NOT NULL,
> b varchar (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
> )
> alter table one
> alter column a {drop} NOT NULL
> alter column b {drop} NOT NULL
> ;
> Thanks,
> Mike
>
How to alter a column
Hi,
What's wrong with the following code? Please help. I am using MS SQL
2000.
create table one (
a float NOT NULL,
b varchar (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
)
alter table one
alter column a {drop} NOT NULL
alter column b {drop} NOT NULL
;
Thanks,
MikeSyntax usage is incorrect. Please use the below code to modify NOT NULL to N
ULL
alter table one alter column a Float NULL
alter table one alter column b Varchar(50) NULL
Thanks
Hari
"Michael" wrote:
> Hi,
> What's wrong with the following code? Please help. I am using MS SQL
> 2000.
> create table one (
> a float NOT NULL,
> b varchar (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
> )
> alter table one
> alter column a {drop} NOT NULL
> alter column b {drop} NOT NULL
> ;
> Thanks,
> Mike
>
What's wrong with the following code? Please help. I am using MS SQL
2000.
create table one (
a float NOT NULL,
b varchar (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
)
alter table one
alter column a {drop} NOT NULL
alter column b {drop} NOT NULL
;
Thanks,
MikeSyntax usage is incorrect. Please use the below code to modify NOT NULL to N
ULL
alter table one alter column a Float NULL
alter table one alter column b Varchar(50) NULL
Thanks
Hari
"Michael" wrote:
> Hi,
> What's wrong with the following code? Please help. I am using MS SQL
> 2000.
> create table one (
> a float NOT NULL,
> b varchar (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
> )
> alter table one
> alter column a {drop} NOT NULL
> alter column b {drop} NOT NULL
> ;
> Thanks,
> Mike
>
Subscribe to:
Posts (Atom)