Solved

1 sql command for 2 database

Posted on 2001-09-11
10
140 Views
Last Modified: 2008-03-06
can i write a vb program using 1 sql command connects to 2 odbc connection ? let said want to differentiate the difference between 2 server data.
0
Comment
Question by:david
  • 3
  • 2
  • 2
  • +3
10 Comments
 
LVL 69

Accepted Solution

by:
Éric Moreau earned 100 total points
ID: 6475223
Not at the same time.

You can change your Connection object to open one or the other database and then use your command on the opened connection.
0
 
LVL 1

Expert Comment

by:dekeldate
ID: 6475507
If you want to refer to data from two different dbs using a single SQL command, you could do this in a stored procedure.
0
 
LVL 9

Expert Comment

by:Valliappan AN
ID: 6475671
If you are talking about SQL server, you can access to different databases like this:

select * from db1.dbo.table1, db2.dbo.table1

i.e. use dbname.user.tablename

For different servers, may be you need to open two diff. recordsets and do it.



0
 
LVL 1

Expert Comment

by:sanjeevjain1973
ID: 6475848
In Sql server you can write sql using use database.owner.table name in from clause

& in Oralce you can creat link to use other database(user) in from clause. Please see the hel to how to create link of other database(user). That link can use from clause, so you can use more then one  database in a single sql statment.

Sanjeev
0
 
LVL 1

Expert Comment

by:sanjeevjain1973
ID: 6475851
Created link use, using character @
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 43

Expert Comment

by:TimCottee
ID: 6475964
With SQL Server 7 and above you can create linkedservers and remote servers which can be used in distributed transactions. With Access also you can use the IN clause to affect data in other access databases.
0
 

Author Comment

by:david
ID: 6484350
thanks guys for your help.
But I need to do is trying to connect 2 different database server. (not database - > in a single server).by using 1 sql command. any idea's ??
0
 
LVL 69

Expert Comment

by:Éric Moreau
ID: 6484957
You can link one of the server to the other.
0
 
LVL 43

Expert Comment

by:TimCottee
ID: 6486921
As I said earlier (and emoreau did just now) create a linked server and you can use data from both in the same transaction.
0
 
LVL 43

Expert Comment

by:TimCottee
ID: 6519273
What is the status david?
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now