Hi,
I've currently hit a problem when using SQL Server 2000 with Access XP via ODBC / OLEDB from SQL Server by Microsoft.
I have a table with two main fields I'm trying to query:
Doing a simple SELECT statement in T-SQL will return both columns with the correct data type format. However if I run the following T-SQL statement:
... actual_other_cost comes back as a string column with a comma separated value, e.g. "581,060,111.22" left justified. If I use a cast to convert the SUM to a decimal (15,2) like so:
... the SUM'ed column comes back with the correct data format as a decimal value of 581060111.22.
So, why do I need to use the CAST on a SUM aggregate function? is there a way to force the correct answer? And where does the problem likely reside? Access, ODBC, SQL Server 2000?
Any help would be greatly appreciated.
Thanks,
Mike Berry-Porter
mikebp@gallery-software.com
I've currently hit a problem when using SQL Server 2000 with Access XP via ODBC / OLEDB from SQL Server by Microsoft.
I have a table with two main fields I'm trying to query:
Code:
district_code as varchar(4)
actual_other_cost as decimal(15,2)
Doing a simple SELECT statement in T-SQL will return both columns with the correct data type format. However if I run the following T-SQL statement:
Code:
SELECT district_code, SUM(actual_other_cost) as actual_other_costs
FROM work_order_actuals
GROUP BY district_code
Code:
SELECT district_code, CAST(SUM(actual_other_cost) as decimal(15,2)) as actual_other_costs
FROM work_order_actuals
GROUP BY district_code
... the SUM'ed column comes back with the correct data format as a decimal value of 581060111.22.
So, why do I need to use the CAST on a SUM aggregate function? is there a way to force the correct answer? And where does the problem likely reside? Access, ODBC, SQL Server 2000?
Any help would be greatly appreciated.
Thanks,
Mike Berry-Porter
mikebp@gallery-software.com