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:
01654323
Views:
73
>>>>>>>>Thank you. I may break the query just to be sure that the user has access to the second database. Also, I don't like to use the DB name in the query (it would be hard-coding it). I prefer to use a handle.
>>>>>>>
>>>>>>>Nope, you can not use handles.
>>>>>>>You must use DataBaseName :-)
>>>>>>
>>>>>>I wonder if I can use a pseudo name for the DB so that I don't have to hard-code it in my query.
>>>>>
>>>>>Nope, you can't.
>>>>>But you can create Synonyms in you database to create instance of table from other database and then use that synonym like table.
>>>>
>>>>Could you, please, give me an example on how to create a synonym?
>>>
>>>CREATE SYNONYM schemaname.SynonymName FOR DataBaseName.Schema.TableName
>>>
>>>Than you can use it:
>>>
>>>SELECT * FROM YourTable
>>>INNER JOIN schemaname.SynonymName ON ...
>>>
>>
>>Thank you. Is CREATE SYNONYM a VFP command or SQL Server command? ( I cannot find it in VFP help)
>
>SQL Server one.

Actually I found that I can create a variable for the 2nd DB and set the name of the DB (on log in) to the variable. This way, the SQL Select uses the variable and the code is not hard-coded to the name of the DB. So far it works.
Thank you all.
"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
Previous
Reply
Map
View

Click here to load this message in the networking platform