Solved

1 sql command for 2 database

Posted on 2001-09-11
10
139 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

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…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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 Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

760 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