vb.net - Syntax Error in From Clause deleting MSystem table records, relationship issue -


i looking delete relationship created code in access 2007 db, using vb.net. db may have been upgraded older level.

so here has been done, open db ado connection string, db encrypted , password protect, open in mode =12, exclusive rights. works. grant select, delete, , alter permissions on msysobjects, , msysrelationships admin user.

the issue relationship used guid, stored in these system tables text, can not deleted tables relationship made, ie.

alter table [mytable] drop constraint '{d86827c0-some-guid-6a6449f1fb07}'; 

or

alter table [mytable2] drop constraint '{d86827c0-some-guid-6a6449f1fb07}'; 

this fails becuase guid can not found on table, have tried tables on both sides of relationship. able szrelationship value, how have apply above alter query, yet stated, not found relationship name on either table. led me believe db may have been migrated older access. system object tables show relationship, know exists , appears in relationships diagram. can deleted there manually. have hundreds of dbs needs edit though.

so alternate approach delete directly 2 system tables.

delete [msysobjects], [msysrelationships] [msysobjects]  inner join [msysrelationships] [msysobjects].[name] = [msysrelationships].[szrelationship]  , [msysobjects].[name] = '" & relationname & "'; 

but returns syntax error on clause. have searched high , low alternative statements try , debug one, not luck...this link provided samples , starting point syntax.

delete 2 tables in 1 query

as turns out syntax error on alter statement needed these [ ]....

alter table [mytable] drop constraint [{d86827c0-some-guid-6a6449f1fb07}]; 

works now.


Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

node.js - Node - Passport Auth - Authed Post Route hangs on form submission -

Does Firefox offer AppleScript support to get URL of windows? -