1 sql command for 2 database

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.
davidAsked:
Who is Participating?
 
Éric MoreauSenior .Net ConsultantCommented:
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
 
dekeldateCommented:
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
 
Valliappan ANSenior Tech ConsultantCommented:
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
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
sanjeevjain1973Commented:
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
 
sanjeevjain1973Commented:
Created link use, using character @
0
 
TimCotteeHead of Software ServicesCommented:
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
 
davidAuthor Commented:
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
 
Éric MoreauSenior .Net ConsultantCommented:
You can link one of the server to the other.
0
 
TimCotteeHead of Software ServicesCommented:
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
 
TimCotteeHead of Software ServicesCommented:
What is the status david?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.