SQL SET DEFAULT not working in MS Access
Support for DEFAULT
was included in Access DDL with Jet 4 (Access 2000). However it can only be used in DDL executed from an ADO connection.
This worked with Access 2007.
CurrentProject.Connection.Execute "ALTER TABLE MyTable " & _
"ALTER COLUMN field2 SET DEFAULT ""foo"";"
Note if your db file is Access 97 or earlier, you won't be able to set a field DEFAULT
value from DDL.
Database Access Mdb how to set a default value to existing column via SQL
I solved using AxBase from SourceForge.net.
I could properly open the *.mdb database and run the above SQL commands and they worked perfectly:
ALTER TABLE Members ALTER COLUMN Privacy SET DEFAULT 1
SQL to add column with default value - Access 2003
Tools -> Options -> Tables/Queries -> (At the bottom right:) Sql Server Compatible Syntax - turn option on for this database.
then you can execute your query:
ALTER TABLE documents ADD COLUMN membersOnly NUMBER DEFAULT 0
Related Topics
How to Give an Alias to a Table in Oracle
Sqlite String Contains Other String Query
How to Remove the First Characters of a Specific Column in a Table
Postgresql: Full Text Search - How to Search Partial Words
How to Insert into a Table with Just One Identity Column
SQL Server 2008 Iif Statement Does Not Seem Enabled
Writing Unicode from R to SQL Server
Alter a SQL Server Function to Accept New Optional Parameter
Using a Conditional Update Statement in SQL
Curious Issue with Oracle Union and Order By
Order by with Inner Query, Giving Ora-00907 Missing Right Parenthesis
What Are the Uses for Cross Join
How to Calculate an Exponential Moving Average on Postgres
Insert Multiple Rows into Db2 Database