-
I have an SQL for extracting data from 2 tables. However the 2 tables have a different connection each as they are located in different databases. This is easy in Microsoft Access but I can't figure it in VB. How can I create a connection/command that is able to extract data this way (if it is possible)?
-
In SQL server when tables are in different databases you can reference them by the following syntax.
<server>..<table>.<field>
so a query would look like this for example:
"SELECT <Database1>..<table1>.<field1> , <field2> , <field3> FROM <Database1>..<table1> , <table2>"
field2 and field3 are in the same database - lets say database2 for demonstration purposes, field1 is on the same server but in database1. The connection is pointing at database2.
Hope this helps
-
As long as the databases are on the same server....
Otherwise you'll need to do something like use Access to link to the tables, with your program reading the data from Access...