Solved

1 sql command for 2 database

Posted on 2001-09-11
10
143 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

732 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