Create Table Syntax Error - MS Access, SQL view

前端 未结 4 1957
星月不相逢
星月不相逢 2021-01-25 03:15

I keep getting CREATE TABLE Syntax Error, but I don\'t see the error! What is causing the error?

My SQL:

CREATE TABLE my_employee
(
e         


        
4条回答
  •  暖寄归人
    2021-01-25 04:00

    Since your DDL statement includes DEFAULT, you must execute it with ADO. I loaded your statement into a string variable and executed it from Access 2007 like this:

    CurrentProject.Connection.Execute strSql
    

    The salary field is decimal with precision 8, scale 2, and default 15000.

    DEFAULT is one of the Access SQL features added with Jet 4.0. Those features are not available for a statement executed from DAO. If you are using Access' query designer to create and execute the statement, you're using DAO. Same if you were using CurrentDb.Execute. But CurrentProject.Connection is an ADO object, so it can .Execute Jet 4.0 features.

    Note NOT NULL is not necessary after PRIMARY KEY since PRIMARY KEY implies NOT NULL. However PRIMARY KEY NOT NULL does not trigger an error. The statement works as you originally wrote it as long as you execute it from ADO.

提交回复
热议问题