Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SQL Decimal places
Message
 
 
À
24/02/2015 13:21:08
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows 7
Network:
Windows 2008 Server
Database:
Visual FoxPro
Application:
Desktop
Divers
Thread ID:
01615791
Message ID:
01615794
Vues:
46
If you're talking about SQL code for VFP tables, then use CAST (VFP 9.0) to get the result with desired number of decimals.

For SQL Server the rules are quite interesting and complex. You may find my article on this helpful:

http://social.technet.microsoft.com/wiki/contents/articles/17910.how-sql-server-determines-type-of-the-constant.aspx

>Hi All:
>
>What determines the length of a calculated numeric field in SQL? In the following example I was expecting no decimal places, since the calculated field in the first record was 0. However, lo and behold, the structure is N(10, 4). Where did the SQL get that?
>
>I used this test because in the real environment I was getting either '0' or '*' in all the records and I was trying to figure out a way to 'force' a N(10, 5).
>
>
>SQL Code
>SELECT *, num1/num2 num3 ;
>FROM test ;
>INTO CURSOR curtest
>
>Table Test structure
>Num1  3, 0
>Num2  3, 0
>
>CurTest Structure
>Num1  3, 0
>Num2  3, 0
>Num3  10, 4
>
>Data in Test
>Num1    Num2
>0            4
>500        49
>500        3
>
>Data in curTest
>Num1    Num2   Num3
>0            4             0.0000
>500        49           1.0020
>500        3          166.6667
>
>
>Thanks,
>
>Yossi
If it's not broken, fix it until it is.


My Blog
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform