Have you tried CASTing your sum(total) to the precision you want? Then you're 
not leaving it up to the query engine to decide.

--

rk

-----Original Message-----
From: ProfoxTech [mailto:[email protected]] On Behalf Of rafael 
copquin
Sent: Friday, March 25, 2016 11:01 AM
To: [email protected]
Subject: problem with calculations with VFP9 and MSSQL Server

A few months ago I posted the following:

quote

I am selecting a bunch of invoices from a MS SQL Server table. I just want to 
add the total of all
invoices.
  
In the management studio I do this:
  
Select sum(total) as total from terbo.dbo.invoices
  
I get 212649.17
  
When I do the same calculation in VFP
  
cCmd = ‘Select sum(total) as total from terbo.dbo.invoices’
sqlexec(thisform.nHandle,cCmd,’curTotals’)
  
nTotal = curTotals.total
  
nTotal  is 212.65
  
How can I get the correct amount?
  
unquote

I would still know the answer to this problem, because the weird thing is that 
it only happens with the tables
of just one database. That  is, I have two similar databases, with similar 
tables. However, the vfp cursor obtained
from this particular database table gives the above error where a similar table 
in another database does not.

In both my Windows 10 and VFP9 SP2 the regional settings are a dot as a 
thousands separator, a comma as
  a decimal point and a semicolon as lists separator. These are the Spanish 
language settings for numbers

The numerical fields in the tables are defined as numerical (18,2) not null 
with a default value of 0

A select statement such as this:

cCmd = 'select invtotal from mydatabase.dbo.invoices where invid = 
'+transform(nPK)
sqlexec(nHandle,cCmd,'curInvTotal')

brings a cursor where a browse shows  12.256,85 (note the dot shown as a 
thousands separator. It should show as
12256,85)  If I place the mouse over the invtotal column on the browse, the 
number shows as 12.25

I am really baffled and do not know what to do.

Any leads on where to tweak the database on SQL Server, or configure the 
software would be appreciated

Any help?

Happy Easter

Rafael Copquin







   
Rafael Copquin


_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox
OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: 
http://leafe.com/archives/byMID/profox/[email protected]
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.
Report [OT] Abuse: http://leafe.com/reportAbuse/[email protected]
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox
OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: 
http://leafe.com/archives/byMID/profox/bn4pr10mb091361305a515e4129efcfc3d2...@bn4pr10mb0913.namprd10.prod.outlook.com
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.

Reply via email to