Constraint Management via SQL


I'm currently working a content management system in C#, that will among other databases support MS Access. Currently I'm working on a patcher that will allow to change the database structure at all the customers. However, when it comes to MS Access I'm having real problems in managing the constraints via SQL.

My first problem is that I cannot seem to be able to remove a NOT NULL constraint dynamically via SQL. I've tried ALTERing the columns and describing them with NULL or nothing at all, but yet the NOT NULL remains.

My other problems is with extracting the current constraints dynamically. The only constraints I can find are the foreign keys in the system tables. I am in need of finding the primary key constraints, the unique constraints, their names and the columns and tables they affect.

Any Access expert who could help me?



  • Syntactically you can do

    [code]CREATE TABLE [Table_Name]
    (Field TEXT(1) NULL)[/code]

    But it doesn't seem to be doing anything - I'm currently trying to get that problem resolved ;-)



    [code]ALTER TABLE tblCustomers
    CONSTRAINT PK_tblCustomers PRIMARY KEY[/code]

    Hope this is what you want.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


In this Discussion