Reputation: 470
I want a MS Access query that can add a column to my current table. Query should include NOT NULL
constraint, DEFAULT
value as ''
i.e. 2 single quotes and the data type.
I tried this query in Access 2007 but this is not working:
ALTER TABLE Demo ADD COLUMN LName TEXT NOT NULL DEFAULT ('')
Upvotes: 0
Views: 2792
Reputation: 757
Try this query:
ALTER TABLE TableName ADD ColumnName(50) NOT NULL
Upvotes: 1
Reputation: 7626
Try this: You need to add size of text column.
ALTER TABLE Demo ADD COLUMN LName TEXT(15) NOT NULL DEFAULT ''
Note: I am adding 15 just as example. You can add whatever is right for ur code.
Upvotes: 0
Reputation: 711
ALTER TABLE {TABLENAME}
ADD {COLUMNNAME} {TYPE} {NULL|NOT NULL}
CONSTRAINT {CONSTRAINT_NAME} DEFAULT {DEFAULT_VALUE}
OR TRY
ALTER TABLE TestTable
ADD NewCol VARCHAR(50)
CONSTRAINT DF_TestTable_NewCol DEFAULT '' NOT NULL
GO
Upvotes: 1