| Author |
Topic |
|
egemen_ates
Yak Posting Veteran
76 Posts |
Posted - 2011-12-27 : 03:10:40
|
| HOW CAN i insert data such as 22/7 into sql server tables. |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-12-27 : 03:24:16
|
| whats the datatype you want to store it in? if its numeric it will only store it in decimal form (ie 3.14..)if varchar you can pass it as '22/7' but if you're doing some manipulations with it then better to store as numeric itself.------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
egemen_ates
Yak Posting Veteran
76 Posts |
Posted - 2011-12-27 : 03:43:55
|
| I STORE '22/7' BUT HOW CAN I USE,FOR EX:I STORE '22/7' SUCH AS VARCHAR,LATER(22/7)*44 HOW CAN I USE THIS FORMAT. |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2011-12-27 : 03:46:20
|
if you stored it as varchar, you will not be able to use it for computation.Can you store the result of 22 / 7 instead ? KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
egemen_ates
Yak Posting Veteran
76 Posts |
Posted - 2011-12-27 : 03:56:44
|
| I EXPLAIN WHAT DO I WANT DO VIA EXAMPLE;FOR EXAPLE;700*22/7=2200 BUT 700*3.14=2199.999999MY PROBLEM IS THIS. |
 |
|
|
egemen_ates
Yak Posting Veteran
76 Posts |
Posted - 2011-12-27 : 03:58:58
|
I EXPLAIN WHAT DO I WANT DO VIA EXAMPLE;FOR EXAPLE;700*22/7=2200 BUT 700*3.14=2199.999999MY PROBLEM IS THISquote: Originally posted by visakh16 whats the datatype you want to store it in? if its numeric it will only store it in decimal form (ie 3.14..)if varchar you can pass it as '22/7' but if you're doing some manipulations with it then better to store as numeric itself.------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/
|
 |
|
|
egemen_ates
Yak Posting Veteran
76 Posts |
Posted - 2011-12-27 : 03:59:20
|
I EXPLAIN WHAT DO I WANT DO VIA EXAMPLE;FOR EXAPLE;700*22/7=2200 BUT 700*3.14=2199.999999MY PROBLEM IS THISquote: Originally posted by khtan if you stored it as varchar, you will not be able to use it for computation.Can you store the result of 22 / 7 instead ? KH[spoiler]Time is always against us[/spoiler]
|
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2011-12-27 : 04:01:27
|
what is the required precision of the calculation result ? 2 decimal places ? round( <result>, 2) it KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
egemen_ates
Yak Posting Veteran
76 Posts |
Posted - 2011-12-27 : 04:08:43
|
| YOU SAY THIS;SELECT ROUND((700*3.14),2)THIS RESULT IS NOT VALID FOR ME,MAYBE CAN YOU SAY OTHER WAY, |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2011-12-27 : 04:10:40
|
[code]declare @f floatselect @f = 22/7.0select round(@f * 70, 2)[/code] KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
egemen_ates
Yak Posting Veteran
76 Posts |
Posted - 2011-12-27 : 04:12:04
|
| SELECT (22/7)*700 IS THIS POSSIBLE? |
 |
|
|
egemen_ates
Yak Posting Veteran
76 Posts |
Posted - 2011-12-27 : 04:14:47
|
| TAHNK YOU THIS WORKING BUT HOW CAN I INSERT 22/7 OR 10/7 INSERT TABLE |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2011-12-27 : 04:19:23
|
use float data typeinsert into yourtable ( float_col)select 22.0 / 7 you need to ensure the value you specify is in decimal else you will get 22/ 7 as 3 and not 3.14xxxxxx KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-12-27 : 04:53:54
|
quote: Originally posted by egemen_ates TAHNK YOU THIS WORKING BUT HOW CAN I INSERT 22/7 OR 10/7 INSERT TABLE
can you turn off caps key while you post? looks really irritatingi didnt understand why you need to see your values as fractions. whats the problem in storing them as decimal with your needed precision and scale limits?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|