How do i set the default value for any area using SQL in MS Access?
I attempted this but got a syntax error:
CREATE TABLE HELLO ( MUN INTEGER NOT NULL, ADD CHAR(50) DEFAULT'16 asd ST.' )
The term ADD is really a keyword. Do this:
CREATE TABLE HELLO ( MUN INTEGER NOT NULL, [ADD] CHAR(50) DEFAULT '16 asd ST.' )
CHAR key phrases are just supported much more the ACE/Jet engine's ANSI-92 Query Mode (after which only in SQL DDL). As Jose Basilio highlights,
ADD is really a reserved word and should be steered clear of using square brackets. Also, you'll need a space between your
DEFAULT word and it is clause (as Jose has proven).
If you're performing the SQL inside a Query object within the MS Access interface you will have to vary from the default (ANSI-89 Query Mode) to ANSI-92 Query Mode. See: About ANSI SQL query mode.
If you're creating the table programmatically e.g. you're using DAO then use a
CurrentProject.Connection.Execute "Sql goes here" where
CurrentProject.Connection is definitely an ADO classic or any other OLE DB link with your computer data source.
P.S. Surely you desired you column to become