Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQLExec() SQL Select from 2 DB
Message
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
01654292
Message ID:
01654293
Views:
74
Likes (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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform