alter table in external database: possible?

N

nico

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
 
N

Niels

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
 
T

Tim Ferguson

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top