Share via

Access 2021 JET SQL: CREATE TABLE with DEFAULT constraint and COMPRESSION in TEXT columns?

Anonymous
2022-11-29T01:38:25+00:00

I'm trying to create a new table using the Database.Execute method:

CREATE TABLE [Test]

  ( [Name] TEXT(50) WITH COMPRESSION NOT NULL

      CONSTRAINT [PK_Appliances] PRIMARY KEY

, [IP] TEXT(15) WITH COMPRESSION NOT NULL

      CONSTRAINT [UK_Appliances_IP] UNIQUE

, [Port] SMALLINT DEFAULT 502 NOT NULL, [TimeoutMS] SMALLINT DEFAULT 1000 NOT NULL , [ProtocolType] TEXT(3) DEFAULT 'TCP' NOT NULL

      REFERENCES [ProtocolType].[Name]

)

I'm getting a syntax error for the "WITH COMPRESSION" and "DEFAULT" clauses.

What am I doing wrong?

Microsoft 365 and Office | Access | For business | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

Anonymous
2022-11-30T01:04:07+00:00

**Note **The WITH COMPRESSION and WITH COMP keywords listed in the previous SQL statements can be executed only through the Jet OLE DB provider and ADO. They will result in an error message if used through the Access SQL View user interface.

Sorry,I guess you are using Access SQL View which is DAO connection rather than vba Ado。

as to Ado connection,the new features are available。

Was this answer helpful?

1 person found this answer helpful.
0 comments No comments

Answer accepted by question author

Anonymous
2022-11-29T10:59:57+00:00

Hi,

Ah, the good old JET 4 SQL documents are still available online. I did some presentations about the 3 of them a 20 years ago. :-)

The doc states in the introduction and other places:

It is very important to note that some of the new SQL syntax is available in code only when you use ActiveX® Data Objects (ADO) and the Jet OLE DB provider, and is not currently available through the Access SQL View user interface or DAO. This article points out when a certain SQL command is available only through the Jet OLE DB provider and ADO.

Well, "not currently available" was an understatement. ;-)

DEFAULT WITH COMPRESSION

were such "new" keywords in JET 4 that still only work when you call them with ADO methods, i.e. build the SQL string in VBA and then execute it like

CurrentProject.Connection.Execute (strSQL)

I'm also not sure if

REFERENCES [ProtocolType].[Name]

will work like this. If it doesn't then try:

REFERENCES [ProtocolType] ([Name])

Servus

Karl

Was this answer helpful?

1 person found this answer helpful.
0 comments No comments

3 additional answers

Sort by: Most helpful
  1. Anonymous
    2022-11-29T13:20:55+00:00

    Thank a lot, Karl, for enlightening me!! 👍

    It's actually been 20 years that I've been moving from MS Access to SQL Server. Returning from SQL Server to Access today appears to be quite a bit of a leap now.

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2022-11-29T08:57:42+00:00

    This is strange … The following Microsoft documentation page tells different:

    https://learn.microsoft.com/en-us/previous-versions/office/developer/office2000/aa140015(v=office.10)?redirectedfrom=MSDN#data-types

    Do I miss something?

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2022-11-29T06:49:23+00:00

    DEFAULT WITH COMPRESSION

    these Keywords are not supported by jet engine。

    Was this answer helpful?

    0 comments No comments