July 30, 2004 at 9:44 am
The formatting method using:
CAST(@MyNumeric AS DECIMAL(8,2)) works OK and data is returned correctly under SQL Query Analyzer.
However, when executing the same Sp in VB 6. Any trailing '0' decimal numerics are truncated. I am using an ODBC SQL Server driver for this. . . . .
So rather than:
SQL-Qry-Analyzer CLIENT
2.00 I get 2
2.10 I get 2.1
3.00 I get 3
. . . . . . . . Does anyone know why this is the case?
Anthony
July 30, 2004 at 9:50 am
try casting as a char(8) and then passing as a string to vb
or in vb use formating to add back the trailing zeros
it's for the same reason that Query analyser returns dates in a different format to your application.
MVDBA
July 30, 2004 at 1:05 pm
I suggest checking your VB code. It appears to be in the way the Client-side displays the value.
VB might have a default that eliminates the trailing zeros.
Remember, SQL Server (or any database) returns the values that it stores. The front-end determines how it is displayed.
-SQLBill
August 2, 2004 at 3:00 am
If you just want VB to display a certain number of decimal places, you should use something like
Format(variable, "0.0000")
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply