Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

drop primary key

Status
Not open for further replies.

virginie

Programmer
Jul 24, 2002
53
IL
hi

i have to delete the primary key through code ( in sql in ms access 2000)
so i try the query : ALTER TABLE Table1 DROP PRIMARY KEY
in sql first to see if it's work before doing this through code.
BUT :i get a "syntax error in alter statement"
and the word PRIMARY is indicated.
someone understand WHY??
THANKS A LOT IF SOMEONE CAN HELP.

VIRGINIE
 
Try using the field name for the Primary key field not the 'Primary Key' attribute.

ALTER TABLE Table1 DROP FieldNameForPrimeKey


G LS
 
I think it should read

ALTER TABLE Table1 DROP CONSTRAINT PRIMARY KEY


Andy
 
But doesn't DROP CONSTRAINT just remove the attribute from the field ?
I think Virginie wants to totally get rid of the field - attributes, name, data and all.


G LS
 
i wanted to leave the field but remove the fact that it is a key.

i try both solutions but it not gives more results...

PRIMARY is maybe not a reserved word in access , so it pass for a name of column??
 
Why do you have to use SQL? Try SQLDMO, set a variable to the Table you want to change and use the Keys collection to remove it. If you don't know what I am talking about set a reference to Microsoft SQLDMO library and use the Object Browser to see the objects that are exposed.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top