SQL to add column with default value - Access 2003

前端 未结 5 1343
悲&欢浪女
悲&欢浪女 2020-11-30 12:59

Updating an old ASP/Access site for a client - I need SQL to add a column to an existing table and set a default value. Doesn\'t work - any ideas?

This works fine

相关标签:
5条回答
  • 2020-11-30 13:28

    Tools -> Options -> Tables/Queries -> (At the bottom right:) Sql Server Compatible Syntax - turn option on for this database.

    is not found on MS Access 2010

    0 讨论(0)
  • 2020-11-30 13:31

    You may find Sql Server Compatible Syntax is already turned on, so definately worth just trying to run the sql statement mentioned above (via an ADO connection from ASP) before resorting to taking the db offline. Thanks, this helped me out.

    0 讨论(0)
  • 2020-11-30 13:37

    With ADO, you can execute a DDL statement to create a field and set its default value.

    CurrentProject.Connection.Execute _
       "ALTER TABLE discardme ADD COLUMN membersOnly SHORT DEFAULT 0"
    
    0 讨论(0)
  • 2020-11-30 13:41

    How are you connecting to the database to run the update SQL? You can use the ODBC compatible mode through ADO. Without opening the database in Access.

    0 讨论(0)
  • 2020-11-30 13:44

    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
    
    0 讨论(0)
提交回复
热议问题