A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Set default value to 0 with ALTER TABLE



 
 
Thread Tools Display Modes
  #1  
Old June 26th, 2008, 08:23 AM posted to microsoft.public.access.queries
Nacho
external usenet poster
 
Posts: 2
Default Set default value to 0 with ALTER TABLE

I have a large database that I need to load massive amounts of data. After
appending the data, numerical fields apear as Null, as no default value was
created.

As I need to create this DB once and again, cannot set the default with
Desing View for Tables.

Traying to use ALTER TABLE "SET DAFULT" command, by always promt for syntax
error:

ALTER TABLE db ALTER COLUMN [my number] SET DEFAULT 0.00;

Have already tryed checking ANSI 92 compatibility, but no luck.

Any idea?

Thks, Rds
Nacho
  #2  
Old June 26th, 2008, 08:55 AM posted to microsoft.public.access.queries
Allen Browne
external usenet poster
 
Posts: 11,706
Default Set default value to 0 with ALTER TABLE

From memory, DEFAULT only works if you execute the query under ADO.

You can set it programmatically under DAO, by setting the DefaultValue of
the Field in the TableDef.

But even when it is set, Access is inconsistent about using it. In different
versions, using different ways of adding records (interface, append query,
recordset, ...) you don't get the same results.

So, you might consider executing an UPDATE query to set the fields to zero
that are null.

Better still: set up the table the way you want it. Then delete the existing
records and append the import, rather than creating and destroying the
table(s.)

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Nacho" wrote in message
...
I have a large database that I need to load massive amounts of data. After
appending the data, numerical fields apear as Null, as no default value
was
created.

As I need to create this DB once and again, cannot set the default with
Desing View for Tables.

Traying to use ALTER TABLE "SET DAFULT" command, by always promt for
syntax
error:

ALTER TABLE db ALTER COLUMN [my number] SET DEFAULT 0.00;

Have already tryed checking ANSI 92 compatibility, but no luck.

Any idea?

Thks, Rds
Nacho


 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 05:49 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.