Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 Database Design and Application Architecture
 format

Author  Topic 

programer
Posting Yak Master

221 Posts

Posted - 2011-05-17 : 16:58:04
Hi,

I would like to save this number: 15.9, not 15,9.

I used numeric(18,2) and decimal (18,2), but not works.

dinakar
Master Smack Fu Yak Hacker

2507 Posts

Posted - 2011-05-17 : 17:00:50
decimal, float should work.. just use the right precision..

Dinakar Nethi
************************
Life is short. Enjoy it.
************************
http://weblogs.sqlteam.com/dinakar/
Go to Top of Page

programer
Posting Yak Master

221 Posts

Posted - 2011-05-17 : 17:15:43
quote:
Originally posted by dinakar

decimal, float should work.. just use the right precision..

Dinakar Nethi
************************
Life is short. Enjoy it.
************************
http://weblogs.sqlteam.com/dinakar/



Yes, but I can not save 15.6. I need to save the number with a dot.
Go to Top of Page

dinakar
Master Smack Fu Yak Hacker

2507 Posts

Posted - 2011-05-17 : 17:21:13
have you tried?
what is the error you get?

Dinakar Nethi
************************
Life is short. Enjoy it.
************************
http://weblogs.sqlteam.com/dinakar/
Go to Top of Page

programer
Posting Yak Master

221 Posts

Posted - 2011-05-17 : 17:25:55
quote:
Originally posted by dinakar

have you tried?
what is the error you get?

Dinakar Nethi
************************
Life is short. Enjoy it.
************************
http://weblogs.sqlteam.com/dinakar/



Invalid value for cell(row 7, column 5

The changed value in this cell was not recognized as valid.
.Net Framework Data Type: Decimal
Error Message: Input string was not in a correct format.


Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-05-17 : 18:45:42
Works fine for me:

declare @n decimal(3,1)
set @n = 15.9
select @n

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

programer
Posting Yak Master

221 Posts

Posted - 2011-05-17 : 19:03:29
quote:
Originally posted by tkizer

Works fine for me:

declare @n decimal(3,1)
set @n = 15.9
select @n

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog



no works.

Please save 15.9 in column odds decimal(3,1).
You'll see that it does not work

help

Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-05-17 : 19:05:40
Yes it does work. That's why I posted the code for it. Try it yourself in Management Studio.

The error you are getting appears to be from your application and not from T-SQL. Since 15.9 fits perfectly into decimal(3,1) as I've shown you, you'll need to fix up your code as this is not a SQL problem.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

programer
Posting Yak Master

221 Posts

Posted - 2011-05-17 : 19:12:25
quote:
Originally posted by tkizer

Yes it does work. That's why I posted the code for it. Try it yourself in Management Studio.

The error you are getting appears to be from your application and not from T-SQL. Since 15.9 fits perfectly into decimal(3,1) as I've shown you, you'll need to fix up your code as this is not a SQL problem.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog



I tried Management Studio but not works.

Do you tried it?

Problem is, since the data are not stored in the form of a dot.

The data in the column can be saved by a comma. This is not good.
Go to Top of Page

dinakar
Master Smack Fu Yak Hacker

2507 Posts

Posted - 2011-05-17 : 19:14:14
is this a new table that you are creating or do you already have a table with data in the X,Y format? And whats the format of your input from the front end?

Dinakar Nethi
************************
Life is short. Enjoy it.
************************
http://weblogs.sqlteam.com/dinakar/
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-05-17 : 19:14:50
YES I TRIED IT! And it works!

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

programer
Posting Yak Master

221 Posts

Posted - 2011-05-17 : 19:20:37
quote:
Originally posted by tkizer

YES I TRIED IT! And it works!

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog



I create new table test (ni povezana z nobeno drugo tabelo)
I create new column "odds" (decimal 3,1).

I tried in management studio save data.

I'm trying to save the studio management information in the form of 15.9. Writes: You got the wrong format.

How do you manage to do this?
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-05-17 : 19:22:06
This works for me:

create table t1 (odds decimal(3,1))

insert into t1 values(15.9)

select * from t1

drop table t1

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

programer
Posting Yak Master

221 Posts

Posted - 2011-05-17 : 19:27:19
quote:
Originally posted by tkizer

This works for me:

create table t1 (odds decimal(3,1))

insert into t1 values(15.9)

select * from t1

drop table t1

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog



Yes it works. However, the stored format of 15,9.
Why not stored 15.9?

Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-05-17 : 19:30:10
I see 15.9 and not 15,9. Perhaps your settings are changing it, although I'm not aware of one for this.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

programer
Posting Yak Master

221 Posts

Posted - 2011-05-17 : 19:35:57
quote:
Originally posted by tkizer

I see 15.9 and not 15,9. Perhaps your settings are changing it, although I'm not aware of one for this.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog




Maybe is problem in the windows system settings
The problem is, because I can not save data in the table with asp.
Go to Top of Page

dinakar
Master Smack Fu Yak Hacker

2507 Posts

Posted - 2011-05-17 : 19:44:19
its possibly due to your locale settings.. need to look this up..

Dinakar Nethi
************************
Life is short. Enjoy it.
************************
http://weblogs.sqlteam.com/dinakar/
Go to Top of Page

dinakar
Master Smack Fu Yak Hacker

2507 Posts

Posted - 2011-05-17 : 20:00:11
windows locale settings - control panel > region and language > Advance settings ..


Dinakar Nethi
************************
Life is short. Enjoy it.
************************
http://weblogs.sqlteam.com/dinakar/
Go to Top of Page
   

- Advertisement -