|
-
May 20th, 2011, 08:24 AM
#1
Thread Starter
Hyperactive Member
Setting Decimals with CREATE TABLE statement
I have the following statement:
Code:
'create a temporary table in ADO_UserData called IHGridSheet
mySQL = "CREATE TABLE IHGridSheet (" & _
"IHDay VarChar(6) NOT NULL, " & _
"IDate DATE, " & _
"IActualWeight SINGLE, " & _
"IExpectedWeight SINGLE, " & _
"IWeightLoss SINGLE, " & _
"IDeviation SINGLE, " & _
"HDate DATE, " & _
"HActualWeight SINGLE, " & _
"HExpectedWeight SINGLE, " & _
"HWeightGain SINGLE, " & _
"HDeviation SINGLE)"
ADO_UserData.Execute mySQL
to create a table in my database (VB6, Access 2000 table and MS Jet 4.0). This works to create the table but...
How do I set the decimals for the SINGLE fields? I want to set 2 decimals. After creating the table with the above statement it is on Auto.
-
May 20th, 2011, 09:12 AM
#2
Re: Setting Decimals with CREATE TABLE statement
You could let that way and control the decimals places in the application side
JG
-
May 20th, 2011, 09:58 AM
#3
Thread Starter
Hyperactive Member
Re: Setting Decimals with CREATE TABLE statement
Could do that but then I still don't know how it is done. Could probably also use a currency field but I want to know how it's done. Previously only needed integer, text and currency field types but now getting into floating point values.
-
May 20th, 2011, 12:24 PM
#4
Re: Setting Decimals with CREATE TABLE statement
Never tried with Access but in SQL Server the syntax to create a table and a numeric field with 2 decimals is :
Code:
CREATE TABLE [dbo].[TableName]
( [NumFieldName] [numeric] (13, 2) )
JG
-
May 20th, 2011, 12:38 PM
#5
Re: Setting Decimals with CREATE TABLE statement
Try :
Code:
CREATE TABLE Test (dec_col DECIMAL(10, 2) NOT NULL)
JG
-
May 20th, 2011, 01:59 PM
#6
Thread Starter
Hyperactive Member
Re: Setting Decimals with CREATE TABLE statement
I tried DECIMAL. It adds two 'fields' to the number data type options of the Access table;
1. Precision
2. Scale
but Decimal Places stays on Auto.
-
May 20th, 2011, 11:55 PM
#7
Re: Setting Decimals with CREATE TABLE statement
AFAIK changeing the Decimal Places, affects only the way the field is displayed not the way the field is stored... so the best, IMO, is as I posted in post #2 : You could let that way and control the decimals places in the application side
JG
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|