How to set default value for Access 2003 field using SQL?

How to set default value for a field using SQL in MS Access?

I tried this but got a syntax error:

CREATE TABLE HELLO
( MUN INTEGER  NOT NULL,
ADD   CHAR(50) DEFAULT'16 asd ST.'
)
+3
source share
2 answers

The word ADD is a keyword. Try the following:

CREATE TABLE HELLO
( 
    MUN INTEGER  NOT NULL,
    [ADD] CHAR(50) DEFAULT '16 asd ST.'
)
+3
source

Keywords DEFAULTand are CHARsupported only in the ANSI-92 ACE / Jet query mode (and then only in SQL DDL). As Jose Bazilio notes, it ADDis a reserved word and must be escaped using square brackets. In addition, you need the space between the word DEFAULTand its sentence (as Jose showed).

SQL Query MS Access, (ANSI-89 Query Mode) ANSI-92. . ANSI SQL.

, , DAO, CurrentProject.Connection.Execute "Sql ", CurrentProject.Connection ADO OLE DB .

P.S. , , HELLO.Mum:)

+3

Source: https://habr.com/ru/post/1707169/


All Articles