P
pnas
I have a table that i need to export to a txt file and the problem is when i
convert to txt a decimal number like 23,343667 it export to txt only 23,34.
convert to txt a decimal number like 23,343667 it export to txt only 23,34.
Access 2003
There is a way to get the numbers to export with more than 2 decimal places
--save the table as a query
--create a calculated field for the number with more than 2 decimalplaces
for example
if you want 6 decimal places, in an empty field in the query type
A:Format([YourNumberField], "0,000000")
--unfortunately this method gives all the numbers exactly the number of decimal places specified in the format
--if your number originally was 23.156 it would be exported as 23.156000
Jamie Collins said:Access 2003
There is a way to get the numbers to export with more than 2 decimal
places
--save the table as a query
--create a calculated field for the number with more than 2 decimalplaces
for example
if you want 6 decimal places, in an empty field in the query type
A:Format([YourNumberField], "0,000000")
--unfortunately this method gives all the numbers exactly the number of
decimal places specified in the format
--if your number originally was 23.156 it would be exported as 23.156000
That would export the data as text, could round values (and do you
know which rounding algorithm?), etc. Perhaps better to work with the
raw data
Use a schema.ini file to specify data types or simply get the engine
to generate one for you e.g. ANSI-92 Query Mode syntax:
CREATE TABLE Test (
dec_col DECIMAL(10, 5) NOT NULL
)
;
INSERT INTO Test (dec_col) VALUES (12345.6789)
;
INSERT INTO Test (dec_col) VALUES (9876.54321)
;
SELECT dec_col
INTO [TEXT;Database=C:\;].NewFile#txt
FROM Test
;
The generated file named 'NewFile.txt' contains this data:
"dec_col"
12345.6789
9876.54321
The generated schema.ini file (but could have been created manually in
order to be different from the mdb's schema if desired) contains the
following information schema:
[NewFile.txt]
ColNameHeader=True
CharacterSet=1252
Format=CSVDelimited
Col1=dec_col Decimal Precision 10 Scale 5
Jamie.
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.