Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SQLExec() SQL Select from 2 DB
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
01654292
Message ID:
01654293
Vues:
73
J'aime (1)
>Hi,
>
>If I am using SQLEXEC to get data, as follows:
>
>lResult = SQLEXEC( SqlHandle, cSqlSelect, cQueryName)
>
>and the cSqlSelect looks like this (simplified):
>
>select Table1.fielda from Table1 left join Table2 on Table1.pk = Table2.pk where table2.field2 = '1234'
>
>The challenge is that the SqlHandle is for SQL Database Table1 and Table2 has a different handle (e.g. SqlHandle2). That is, Table2 is in a different database.
>
>Possible?

Use three part naming to include the name of the database, if the database is on the same instance
select Table1.fielda from Table1 left join db2.dbo.Table2 on Table1.pk = Table2.pk where table2.field2 = '1234' -- assumming the schema is dbo and the database is db2 for table 2
if is not in the same instance then you will need to create a linked server on the first instance and add the linked server in a four part naming [linked server].[database].[schema].[table]
"The five senses obstruct or deform the apprehension of reality."
Jorge L. Borges?

"Premature optimization is the root of all evil in programming."
Donald Knuth, repeating C. A. R. Hoare

"To die for a religion is easier than to live it absolutely"
Jorge L. Borges
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform