Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SQL Select with the second DB
Message
De
29/01/2022 18:05:09
 
 
À
29/01/2022 17:41:55
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
01683370
Message ID:
01683373
Vues:
49
First, thank you for your message.
But this was not my question. Say, I don't use an ALIAS, I wanted to know if I have to use the the SQL Server name before every use of the table in the entire SQL Select expression.

For example, If I take your example and the table TestTable is from a different database, than the default database, do I have to use that different database name?
SELECT TestTable.Name from MySecondSQLServerDatabase.TestTable where MySecondSQLServerDatabase.TestTable.first_name = 'XYZ'
You see the table TestTable is in both the default SQL Server database and in some other SQL Server database (MySecondSQLServerDatabase). So if I don't use this MySecondSQLServerDatabase before the column "first_name", will SQL server select get this column from the default DB or from the second DB (MySecondSQLServerDatabase)?

I probably didn't phrase my questions correctly.

>As a general statement, use an ALIAS after the "from".
>I'm not 100% positive if you're using SQL Passthrough from VFP, but as a general statement, I can do this in SQL server
>
>USE ProductionDB
>GO
>
>SELECT ProdTable.Name as ProductionName, TestTable.Name as TestName
>FROM ProductionTable ProdTable
> JOIN TestDB.TestingTable TestTable
> WHERE ProdTable.SomeKey = TestTable.SomeKey
>
>Once you have the ALIAS, you shouldn't need to have to reference the 2nd database every time (again, to best of my awareness, but I haven't done anything from VFP->SQL in a long time, so you might want to test to be sure)
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform