Change of original column leads to TEXT format in Excel sheet
Вопрос
This select in EXCEL VBA results to numeric format in Excel:
strSQL = "SELECT * FROM OPENQUERY(dtb, 'SELECT col from table')"
But if I make some function on the column, it results as text format in Excel:
strSQL = "SELECT * FROM OPENQUERY(dtb, 'SELECT sum(col) from table')"
strSQL = "SELECT * FROM OPENQUERY(dtb, 'SELECT col*1.0 from table')"
strSQL = "SELECT * FROM OPENQUERY(dtb, 'SELECT col-1 from table')"
I've tried to_number(...)
, to_number(to_char(...))
but it didn't helped.
Why? How can I resolve this situation?
SOLUTION (convert column to numeric using SQL server cast function)
strSQL = "SELECT cast(col# as numeric(10, 2)) col# " _
"FROM OPENQUERY(dtb, 'SELECT sum(col) col# from table')"
Решение
SOLUTION (convert column to numeric using SQL server cast function)
strSQL = "SELECT cast(col# as numeric(10, 2)) col# " _
"FROM OPENQUERY(dtb, 'SELECT sum(col) col# from table')"
Не связан с StackOverflow