Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

1 sql command for 2 database

Posted on 2001-09-11
10
Medium Priority
?
147 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 70

Accepted Solution

by:
Éric Moreau earned 300 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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
 
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 70

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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…
Suggested Courses

824 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