Changing Double to Decimal

J

jabah_cum_jiriumum

Hi,
I'd like to modify a Column in a table that is setted as Double into Decimal
with 4 places.
I try the command ALTER TABLE tab_final ALTER COLUMN txt DECIMAL (15,2) but
it didn't work. Is there some way to do it.
Thanks.
 
G

Guest

Open the table in design view, click on the field, at the bottom change the
Field Size and number of decimal places. Save.
 
A

Allen Browne

As Karl says, it is very easy to do in the table design interface.

It is also possible if you execute your DDL query statement under ADO:
CurrentProject.Connection.Execute strSql

I didn't understand why the 2nd argument is a 2 when you want 4 places.

You should also know that the Decimal field type is very poorly implemented
in Access. Even basic sorting fails. More info:
http://allenbrowne.com/bug-08.html
 
J

Jamie Collins

Allen said:
You should also know that the Decimal field type is very poorly implemented
in Access. Even basic sorting fails. More info:
http://allenbrowne.com/bug-08.html

Hmm, more like 'obscure engine-side sorting fails' i.e. the data must
contain negative values, the sort order must be descending and the
sorting must be done by the engine.

Following your link:

AllenB: "If the [column] is a Decimal type and you ask for descending
order, the sorting is wildly inaccurate...Negative values appear first
(wrong), followed by the positive ones. Nulls and zeros sort
unpredictably - at the beginning, middle or end, depending on the
data."

'Wildly inaccurate' is a bit emotive when you consider the pattern is
entirely predictable.
Yes, the sort order is wrong: first (wrong) the negative (less than
zero) values are correctly sorted in descending order, then positive
values (greater or equal to zero) correctly sorted in descending order,
last (correct) the NULL values.

In my tests, NULL values and zeros always sort predictably. In fact,
the Jet 4.0 spec for collation means NULLs will *always* appear last.
If you can post some code where the engine does not sort NULLs to the
end of the resultset then *that* would be news.

Now we've established the problem, the workaround is simple: do the
sorting in the middleware. For example, you could do the sort in the
recordset:

rs.Sort = "decimal_col DESC"

Jamie.

--
 
J

jabah_cum_jiriumum via AccessMonster.com

Oh Thanks!!!
Using ADO I got my column as Decimal!!!
( Really, my 2nd argument was wrong when I wrote here.)

This is the right query that worked under ADO modifying the Column setted as
Double into Decimal with 4 places:
CurrentProject.Connection.Execute ("ALTER TABLE tab_final ALTER COLUMN txt
DECIMAL (15,4)")


Allen said:
As Karl says, it is very easy to do in the table design interface.

It is also possible if you execute your DDL query statement under ADO:
CurrentProject.Connection.Execute strSql

I didn't understand why the 2nd argument is a 2 when you want 4 places.

You should also know that the Decimal field type is very poorly implemented
in Access. Even basic sorting fails. More info:
http://allenbrowne.com/bug-08.html
Open the table in design view, click on the field, at the bottom change
the
[quoted text clipped - 8 lines]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top