Solved

1 sql command for 2 database

Posted on 2001-09-11
10
141 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 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
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 
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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
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.
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 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…

786 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