Changing the default value of a column in Access using a SQL query

A

Alan Arsinow

I am working on a VC++ Windows application that uses an Access database as a
backend. I need a way to change the default value of a column using a SQL
query.

I have tried

ALTER TABLE <table_name> ALTER COLUMN <column_name> SET DEFAULT <value>

however, I get 'Syntax error in ALTER TABLE statement' and the keyword
DEFAULT is highlighted.

I have also tried

ALTER TABLE <table_name> ADD CONSTRAINT <constraint_name> DEFAULT <value>
FOR <column_name>

however, I get 'Syntax error in CONSTRAINT clause' and the keyword DEFAULT
is highlighted.

I am really hoping there's a way to do this. Any help would be appreciated.

Thanks,
Alan Arsinow
 
J

JohnFol

According to the online Help I don;t think you can do it. Here's the
extract. Note it does not mention "SET DEFAULT"

Use ALTER COLUMN to change the data type of an existing field. You specify
the field name, the new data type, and an optional size for Text and Binary
fields. For example, the following statement changes the data type of a
field in the Employees table called ZipCode (originally defined as Integer)
to a 10-character Text field:
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top