alter table in external database: possible?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,
I would like to use SQl "Alter Table" statement in Db1 to modify a table in Db2.
Is it possible?
Which is the right syntax?
Thanks
Nico
 
Hi Nico,
this can help you.

Sub Upgrade()
Dim ws As Workspace
Dim db As Database

Set ws = CreateWorkspace("Temp", "admin", "", dbUseJet)
Set db = ws.OpenDatabase("C:\DB2.mdb", False)

db.Execute ("alter table TabName add column ColName bit
not null")
db.Close
Set db = Nothing
Set ws = Nothing

End Sub


Greetings Niels
 
Which is the right syntax?

You have to open db2 with a

Set dbOther = DBEngine.OpenDatabase("c:\db2.mdb", False, True)
dbOther.Execute "ALTER TABLE etc", dbFailOnError

dbOther.Close


I'm not sure if you can use a IN clause in ALTER TABLE, but I doubt it.

B Wishes


Tim F
 
Back
Top